Any2Quiz
CBSE / 8 / ICT / Programming Basics

Introduction to Loops Quiz - CBSE Class 8 ICT

Free practice quiz: Introduction to Loops (CBSE Class 8 ICT). 19 multiple-choice questions with answers and explanations. Play online, no sign-up needed.

Play all 19 questions free

Sample questions

  1. What is a loop in programming?

    1. A method to repeat a set of instructions
    2. A condition to stop a program
    3. A variable that counts
    4. A type of data structure
    Show answer

    Answer: A. A method to repeat a set of instructions

    A loop is a fundamental concept in programming that allows a set of instructions to be executed repeatedly until a certain condition is met.

  2. In a 'while' loop, when does the loop terminate?

    1. When the condition evaluates to false
    2. After a set number of iterations
    3. Immediately
    4. Before the first iteration
    Show answer

    Answer: A. When the condition evaluates to false

    A 'while' loop continues to execute as long as the condition remains true. It stops when the condition becomes false.

  3. How does a 'do-while' loop differ from a 'while' loop?

    1. A 'do-while' loop executes at least once before checking the condition
    2. A 'do-while' loop cannot run at all
    3. A 'do-while' loop checks condition before execution
    4. They are identical
    Show answer

    Answer: A. A 'do-while' loop executes at least once before checking the condition

    Unlike 'while' loops, 'do-while' loops guarantee at least one execution of their block of code, as the condition is checked after the execution.

  4. What will be the final value of 'i' after the following code is executed? 'int i = 0; while(i < 5) { i++; }'

    1. 0
    2. 5
    3. 6
    4. 4
    Show answer

    Answer: B. 5

    The while loop increments 'i' until it is no longer less than 5, resulting in a final value of 5.

  5. How many times will 'print()' be called in the following code? 'for(int i=1; i<6; i+=2) { print(); }'

    1. 2
    2. 3
    3. 5
    4. 4
    Show answer

    Answer: B. 3

    The loop increments by 2, resulting in calls when i equals 1, 3, and 5—totaling three calls to print().

Take the full quiz

More quizzes

Browse all Programming Basics quizzes