C Programming Questions and Answers – Break and Continue – 1

«
»

This set of C Multiple Choice Questions & Answers (MCQs) focuses on “Break and Continue – 1”.

Pre-requisite for this C MCQ set: Advanced C Programming Video Tutorial.

advertisement

1. Which keyword can be used for coming out of recursion?
a) break
b) return
c) exit
d) both break and return
View Answer

Answer: b
Explanation: None.

2. What will be the output of the following C code?

advertisement
advertisement
  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         int a = 0, i = 0, b;
  5.         for (i = 0;i < 5; i++)
  6.         {
  7.             a++;
  8.             continue;
  9.         }
  10.     }

a) 2
b) 3
c) 4
d) 5
View Answer

Answer: d
Explanation: None.
advertisement

3. What will be the output of the following C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         int a = 0, i = 0, b;
  5.         for (i = 0;i < 5; i++)
  6.         {
  7.             a++;
  8.             if (i == 3)
  9.                 break;
  10.         }
  11.     }

a) 1
b) 2
c) 3
d) 4
View Answer

Answer: d
Explanation: None.
advertisement

4. The keyword ‘break’ cannot be simply used within _________
a) do-while
b) if-else
c) for
d) while
View Answer

Answer: b
Explanation: None.
advertisement

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
View Answer

Answer: b
Explanation: None.

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;
  5.         for (i = 0;i < 5; i++)
  6.         {
  7.             for (j = 0;j < 4; j++)
  8.             {
  9.                 if (i > 1)
  10.                     break;
  11.             }
  12.             printf("Hi \n");
  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
View Answer

Answer: a
Explanation: None.

7. What will be the output of the following C code?

  1.     #include <stdio.h>
  2.     void main()
  3.     {
  4.         int i = 0;
  5.         int j = 0;
  6.         for (i = 0;i < 5; i++)
  7.         {
  8.             for (j = 0;j < 4; j++)
  9.             {
  10.                 if (i > 1)
  11.                     continue;
  12.                     printf("Hi \n");
  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
View Answer

Answer: b
Explanation: None.

8. What will be the output of the following C code?

  1.     #include <stdio.h>
  2.     void main()
  3.     {
  4.         int i = 0;
  5.         for (i = 0;i < 5; i++)
  6.             if (i < 4)
  7.             {
  8.                 printf("Hello");
  9.                 break;
  10.             }
  11.     }

a) Hello is printed 5 times
b) Hello is printed 4 times
c) Hello
d) Hello is printed 3 times
View Answer

Answer: c
Explanation: None.

Sanfoundry Global Education & Learning Series – C Programming Language.

To practice all areas of C language, here is complete set of 1000+ Multiple Choice Questions and Answers.

advertisement
advertisement

Leave a Comment

Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & technical discussions at Telegram SanfoundryClasses.