CS201 – Spring
2003
Prof.
Hartman
Homework
#2
Due Friday, January
31st 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 accept three integers from the keyboard and tell the user whether
or not they were entered in increasing order. (That is, if the user enters
2 5 8
you should print “yes”,
where if they enter 2 8 5
or 8 5 2
your program should print “no”).