CMSC 104 - Quiz 4

Total of 35 points possible - possible point totals for each question are shown as (X) below

  1. (5) True/False: A while loop will run atleast one time.
  2. (9) What are the three parts of a for loop? i.e. for(__1___; __2___; __3__)

    1. ___________
    2. ___________
    3. ___________
  3. (4) When compiling what flag must you add to use the math library? i.e. "-?"
  4. (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;
    }
  5. (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;
    }