CS 215: UNIX C Programming

Review for Quiz 2
 

  1. The statements of a program found between the two braces of a while loop are called a(n) _______.
    1. square
    2. block
    3. area
    4. unit


  2. A while loop continues to execute (to loop) until the test condition becomes _______.
    1. true
    2. false
    3. null
    4. equal


  3. Which one of the following assignment statements is valid?
    1. 2000 = i + 2;
    2. i + 2 = 2,000;
    3. i = i + 2,000;
    4. i = 2 + 2000;


  4. With integer division, which is the value of 5 divided by 4?
    1. 0
    2. 1
    3. 1.2
    4. 2


  5. What is the value assigned to the integer variable, butter, given the statement butter = 25.0 + 60.0 * 5/10;
    1. 0
    2. 32
    3. 42.5
    4. 55


  6. What is the value of the variable, score, given the statement score = -7 * 6 + (4 + 3 * (2 + 3));
    1. -23
    2. -7
    3. 6
    4. 61


  7. Which of the following means the same as the statement x = x + 1;
    1. x++;
    2. x+;
    3. ++x;
    4. Both a and c are correct answers.


  8. What is the value of the variable, nextrun, given the statements y = 2; n = 3; nextrun = (y + n++) * 6;
    1. 21
    2. 26
    3. 30
    4. 36


  9. Which of the following is the postfix form of the decrement operator?
    1. count --
    2. -- count
    3. count -
    4. - count


  10. Repeating a sequence of statements until some condition is met is best known as ______.
    1. sequencing
    2. looping
    3. branching
    4. checking


  11. Using a test to decide between alternative sequences is best known as _____.
    1. sequencing
    2. looping
    3. branching
    4. checking


  12. For a while loop to terminate its execution, the value of the test expression must eventually become _____.
    1. equal to high
    2. equal to low
    3. true
    4. false


  13. All of the following are relational operators except which one?
    1. >
    2. =
    3. <=
    4. !=


  14. The expression 5 > 2 is ___ and has a value of ___.
    1. true, 0
    2. true, 1
    3. false, 0
    4. false, 1


  15. Which of the following is (are) involved in setting up a loop that is repeated a fixed number of times?
    1. A counter must be initialized.
    2. The counter must be compared with some limiting value.
    3. The counter is incremented each time the loop is traversed.
    4. All of the above are involved.


  16. Which part of the following for loop is the initialization expression? for(count = 1; count <= num; count++) printf("Loop");
    1. count = 1
    2. count <= num
    3. count++
    4. printf("Loop");


  17. The for loop is a(n) ___-condition loop.
    1. early
    2. exit
    3. easy
    4. entry


  18. Which of the following statements means the same as time /= 2.73;
    1. time = time + time/2.73;
    2. time = time/2.73;
    3. time = time + 2.73;
    4. time = time/2.73 + time/2.73;


  19. What is the minimum number of times the block within a do-while loop will be executed?
    1. Minus one times.
    2. Zero times.
    3. One time.
    4. More than one time.


  20. Which of the following is used to reference the 5th element of the array debt, which is declared as follows: float debt[30];
    1. debt[4]
    2. debt[5]
    3. debt[6]
    4. Either a or b are correct.


  21. The statement in following general form is executed, if the expression is found to be ____. if (expression) statement;
    1. false
    2. high
    3. true
    4. low


  22. Which of the following getchar() statements is valid?
    1. ch = getchar(c);
    2. ch = getchar(&c);
    3. ch = getchar();
    4. Both a and c are correct answers.


  23. Which of the following is equivalent to the expression ! (4 > 7)
    1. ! (4 <= 7)
    2. ! (4 < 7)
    3. 4 <= 7
    4. 4 < 7


  24. The general form of the conditional expression is
    1. expression1 : expression2 ? expression3
    2. expression1 ? expression2 : expression3
    3. expression1 ? expression2 ? expression3
    4. expression1: ?expression2 : expression3


  25. When a ___ statement is encountered in a loop, it causes the rest of the iteration to be skipped and the next iteration of the loop to be started.
    1. case
    2. goto
    3. break
    4. continue


  26. A ___ statement in a loop causes the remainder of the iteration to be skipped and does not start the next iteration of the loop.
    1. case
    2. goto
    3. break
    4. continue


  27. When a program needs to choose from one of several alternatives, which statement is advised?
    1. case
    2. continue
    3. goto
    4. switch


  28. Which statement is usually the last statement for every case in a switch statement?
    1. continue
    2. goto
    3. break
    4. jump


  29. In principle, how many goto statements should be placed in every C program?
    1. 0
    2. 1
    3. 2
    4. There is no upper limit.


  30. All of the following are forms of jump statements except which one?
    1. if
    2. goto
    3. continue
    4. break


  31. Which of the following operators is the logical OR operator?
    1. &&
    2. ||
    3. !
    4. !!