Break and Continue MCQ Ans
Break and Continue MCQ Ans
Break and Continue MCQ Ans
Answer: b
1. #include <stdio.h>
2. int main()
3. {
4. int a = 0, i = 0, b;
6. {
7. a++;
8. continue;
9. }
10. }
a) 2
b) 3
c) 4
d) 5
Answer: d
1. #include <stdio.h>
2. int main()
3. {
4. int a = 0, i = 0, b;
6. {
7. a++;
8. if (i == 3)
9. break;
10. }
11. }
a) 1
b) 2
c) 3
d) 4
Answer: d
Answer: b
5. Which keyword is used to come out of a loop only for that iteration?
a) break
b) continue
c) return
d) none of the mentioned
Answer: b
6. What will be the output of the following C code?
1. #include <stdio.h>
2. void main()
3. {
4. int i = 0, j = 0;
6. {
8. {
9. if (i > 1)
10. break;
11. }
13. }
14. }
a) Hi is printed 5 times
b) Hi is printed 9 times
c) Hi is printed 7 times
d) Hi is printed 4 times
Answer: a
1. #include <stdio.h>
2. void main()
3. {
4. int i = 0;
5. int j = 0;
7. {
9. {
10. if (i > 1)
11. continue;
13. }
14. }
15. }
a) Hi is printed 9 times
b) Hi is printed 8 times
c) Hi is printed 7 times
d) Hi is printed 6 times
Answer: b
1. #include <stdio.h>
2. void main()
3. {
4. int i = 0;
6. if (i < 4)
7. {
8. printf("Hello");
9. break;
10. }
11. }
Answer: c
1. #include <stdio.h>
2. void main()
3. {
4. int i = 0;
5. if (i == 0)
6. {
7. printf("Hello");
8. continue;
9. }
10. }
Answer: d
2. What will be the output of the following C code?
1. #include <stdio.h>
2. void main()
3. {
4. int i = 0;
5. if (i == 0)
6. {
7. printf("Hello");
8. break;
9. }
10. }
Answer: d
1. #include <stdio.h>
2. int main()
3. {
4. int i = 0;
5. do
6. {
7. i++;
8. if (i == 2)
9. continue;
13. }
a) In while loop 2
b) In while loop in while loop 3
c) In while loop 3
d) Infinite loop
Answer: a
1. #include <stdio.h>
2. int main()
3. {
4. int i = 0, j = 0;
7. {
8. printf("1\n");
9. break;
10. }
11. printf("2\n");
12. }
14. }
a)
after loop
b)
after loop
c)
after loop
d)
after loop
Answer: c
1. #include <stdio.h>
2. int main()
3. {
4. int i = 0;
5. while (i < 2)
6. {
7. if (i == 1)
8. break;
9. i++;
10. if (i == 1)
11. continue;
13. }
15. }
a)
In while loop
After loop
b) After loop
c)
In while loop
In while loop
After loop
d) In while loop
Answer: b
1. #include <stdio.h>
2. int main()
3. {
4. int i = 0;
5. char c = 'a';
6. while (i < 2)
7. {
8. i++;
9. switch (c)
10. {
13. break;
14. break;
15. }
16. }
18. }
a) a after loop
b) a a after loop
c) after loop
d) error
Answer: b
1. #include <stdio.h>
2. int main()
3. {
5. continue;
6. printf("after continue\n");
7. }
Answer: d