NAME

Question types


Start with


Question limit

of 13 available terms

Print test

13 True/False questions

  1. What is the cause of the bug that is known as the infinite loop?The variable is not auto incremented, so it repeatedly traverses the same index value in the array.


    #include <stdio.h>

    int main()
    {
    char letters[] = {'a','b','c'};
    int w = 0;
    do
    {
    printf("letter %d is %c \n", w, letters[w]);
    ++w; }
    while (w<4);

    return 0;
    }

          

  2. How many times will the following loop execute?

    int i = 0;
    while ( i < 1 ) {
    printf("looping");
    }
    Infinite because it neglects the auto incrementation of the variable within the conditional expression.

          

  3. Is the do while loop frequently used in practice?No it is not. The for loop and while loop are used for when you want to traverse arrays or do any other type of looping.

          

  4. How would you access the second element from a character array named "letters".

    char letters[] = {'a','b','c','d'};
    letters[1];

          

  5. Explain this for loop.
    {
    for (int i=0; i<12; i++)
    {sum += evens[i];
    printf("sum %d \n", sum);

    }
    return 0;

    }
    The for loop has three statements within the set of parentheses.
    a. First we are initializing an integer variable "i" to "0"
    b. Second a Boolean expression which "i", to the number of items in the array (3).
    c. Thirdly we are auto incrementing "i" if the value of the index is <12.

    (i) Then within the code block {} we are incrementally summing the values that are in the array "even".

    (ii) w/in the block we are indexing the variables using the variable "i".

          

  6. What is a loop?Simply allow for executing a block of code without providing any construct for keeping a counter.

          

  7. What is the purpose of a do while conditional expression?Simply allow for executing a block of code without providing any construct for keeping a counter.

          

  8. What is inside the parenthesis?

    for (int i=0; i<12; i++)
    The for loop has three statements within the set of parentheses.
    a. First we are initializing an integer variable "i" to "0"
    b. Second a Boolean expression which "i", to the number of items in the array (3).
    c. Thirdly we are auto incrementing "i" if the value of the index is <12.

    (i) Then within the code block {} we are incrementally summing the values that are in the array "even".

    (ii) w/in the block we are indexing the variables using the variable "i".

          

  9. How many times will the following loop execute?

    int i = 1;
    do {
    printf("looping");
    }
    while ( i < 1 ) ;
    once

          

  10. What are the While and do while loops?Simply allow for executing a block of code without providing any construct for keeping a counter.

          

  11. Which of the following is not a looping construct?do-until loop

          

  12. What are the drawbacks of the while and do while loops?Simply allow for executing a block of code without providing any construct for keeping a counter.

          

  13. Which is a valid for loop that will execute exactly 5 times?No it is not. The for loop and while loop are used for when you want to traverse arrays or do any other type of looping.