Loops Interview Questions

    Question 1: For Loop Iterations

    How many times does the loop run in for (int i = 0; i < 10; i++)?

    Question 2: While Loop Condition

    Which statement about the while loop is true?

    Question 3: Do-While Loop

    What is the key difference between a while and a do-while loop?

    Question 4: Break Statement

    What does the break statement do inside a loop?

    Question 5: Continue Statement

    What does the continue statement do inside a loop?

    Question 6: For Loop Output

    What will be printed?

    #include <stdio.h> int main() { for (int i = 1; i <= 3; i++) { printf("%d ", i); } return 0; }

    Question 7: While Loop Execution

    What will be the output?

    #include <stdio.h> int main() { int i = 0; while (i < 3) { printf("Hi "); i++; } return 0; }

    Question 8: Nested Loop

    If an outer loop runs 5 times and an inner loop runs 4 times, how many total iterations occur?

    Question 9: Infinite Loop

    Which of these will create an infinite loop?

    Question 10: Loop Control

    Which loop is best suited when the number of iterations is known in advance?