CS201 – Spring 2001
Prof. Hartman
Homework #2
Due Friday, February 2nd
by 5:00 pm
1) Assume x=8 and y=11. What is printed by the following statements?
a.
cout
<< "The number is " << x << ".\n";
b.
cout
<< "The number is x .\n";
c.
cout
<< "The number is \nx.\n";
d.
cout
<< y % x;
e.
cout
<< x % y;
2)
Write
a program to do the following. Input two integers from the keyboard. Output the
remainder when the first is divided by the second, if possible (that is, if the
second is not zero). If this is impossible to do, inform the user.
3)
Write
a program to print a 4 by 7 rectangle made of asterisks, as shown below.
****
****
****
****
****
****
****
4)
Write
a program to accept two integers (possibly negative) from the keyboard and tell
the user which has the greatest square.
5)
Write
a program to print a table of integers from 1 to 20 with their squares and
cubes.
6)
Write
a program to input a 5 digit number from the keyboard, and then print it with
its digits in reverse order. For
instance, if the user types 14952, the program should print 25941. (Hint: Use / and %.)