Sunday, August 2, 2009

In perl programming what is a complete code that write a program that reads two integers from standard input?

(one at a time), divides the first one by the second one, and prints out the quotient (the result) and the remainder?

In perl programming what is a complete code that write a program that reads two integers from standard input?
use %26lt;STDIN%26gt; or %26lt;%26gt; and go from there.
Reply:This is not by any change a homework isn't it? :-)





You will need %26lt;STDIN%26gt; or %26lt;%26gt; to get the values, probably some regex or "split" to parse the value out if you want both integers are entered in one line (see perlre and perlsyn). The calculating construct you can find in perlop (search for "divide" and "modulus") and perlfunc (search for "integer portion"). If you want to do this multiple time, you will need put everything in a "while" loop (read perlsyn).





To read documentation you can issue a command:





perldoc perlsyn


perldoc perlfunc


perldoc perlop





or from perldoc site below.

plants

No comments:

Post a Comment