Any2Quiz
Quizzes / CBSE / Class 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.

This CBSE Class 8 ICT practice quiz has 19 multiple-choice questions on Introduction to Loops, and 19 of them come with an explanation. Try the 5 sample questions below (tap an option to check yourself), then play the full quiz online. No sign-up needed.

Start quiz: 19 questions, free

Sample questions

  1. What is a loop in programming?

    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?

    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?

    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++; }'

    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(); }'

    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 questions in this quiz

Answers and explanations are in the full quiz.

  1. Which of the following is NOT a type of loop?
  2. What does a 'for' loop do?
  3. What is an infinite loop?
  4. Which of the following can cause an infinite loop?
  5. What is the purpose of a 'break' statement in a loop?
  6. If a for loop iterates 5 times and has a break statement that is executed on the 3rd iteration, how many times will the loop actually run?
  7. What is the output of the following code? 'for(int i=0; i<5; i++) { if (i == 3) break; print(i); }'
  8. In which situation would you prefer a 'while' loop over a 'for' loop?
  9. If you have nested loops, how many times will the inner loop run if the outer loop runs 3 times and the inner loop runs 4 times?
  10. What is the value of 'total' after the following code is executed? 'int total=0; for(int i=1; i<=3; i++) { total+=i; }'
  11. What will happen if the condition in a 'for' loop is always true?
  12. What is the effect of adding 'continue' inside a loop?
  13. In nested loops, which loop runs more times?
  14. Why is it important to use a terminating condition in loops?

More quizzes

Browse all Programming Basics quizzes

More to play

Daily ChallengeA new quiz every day. Keep your streak.HangmanGuess the word, letter by letter.Story QuestLearn through short interactive stories.All quizzesCBSE, ICSE, competitive exams and more.