LoginSignup
0
0

More than 1 year has passed since last update.

主な計算~Ruby~

Posted at

数値と足し算・引き算

  • プログラミングの世界では文字列と数値は別物である。""を使う事で、認識される。

足し算→+
引き算→-

puts 5+2
puts "5+2"

出力結果

7
5+2

掛け算・割り算・余りの計算

  • 掛け算は「*」(アスタリスク)
  • 割り算は「/」(スラッシュ)
  • 「%」を用いると、割り算の余りを計算できる。
puts 3*5
puts 6/2
puts 9%2

出力結果

15
3
1
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0