CMSC 104 - Quiz 4
Total of 35 points possible - possible point totals for each question are shown as (X) below
- (5) True/False: A while loop will run atleast one time.
-
(9) What are the three parts of a for loop? i.e. for(__1___; __2___; __3__)
- ___________
- ___________
- ___________
- (4) When compiling what flag must you add to use the math library?
i.e. "-?" - (5) Convert the following for loop into a while loop. There may be statements required before the loop itself:
#include <stdio.h>
int main(void)
{
int x;
for(x = 0; x < 10; x++){
printf("%d\n",x);
}
return 0;
}
- (12) What is the output of the following program:
#include <stdio.h>
int main(void)
{
int x, y;
for(x = 0; x < 6; x++){
y = 0;
while( y < 2){
printf("%c",'*');
y++;
}
printf("\n");
}
return 0;
}