I. Trace through the following loop, keeping track of the values of the variables.
int total=3;
double w=1.2;
do {
if ( w > 3 ) total=6;
w=w+0.5;
} while ( w < 3.5 );
II. Same thing...
int k=4;
double x=0;
while (k>2) {
m=1;
while (m<=2) {
x=x+k;
++m;
}
k=k-1;
}
III. Show what gets displayed on the screen.
double BlackBox(double z, int n)
{
cout << z << ", " << n+z << endl;
return 3*z;
}
void main()
{
int mm;
mm=BlackBox( 1.0, 4);
cout << mm;
}
IV. Show what gets displayed on the screen.
void proc1(int m) { cout << m << endl; }
void proc2()
{
proc1(3);
cout << "in proc2\n";
}
void main()
{
cout << "Starting\n";
proc2();
proc1(5.2);
}