割り算の余りは、% で求める。 remainder.rb
#!/usr/koeki/bin/ruby
STDERR.print("余りを出します。割られる数はいくつ?\n")
dividend = gets.to_i # 割られる数を dividend とする
STDERR.print("割る数はいくつ?\n")
modulus = gets.to_i # 割る数を modulus とする
quotient = dividend / modulus # 商を quotient とする
remainder = dividend % modulus # 余りを remainder とする
printf("商 は %d で余りは %d です\n", quotient, remainder)
printf("もとの数は %d でした\n", quotient * modulus + remainder)
なぜ、このプログラムで商が出てくるのか、 手計算で変数に入っているはずの値を追いかけながら、調べよ。