C Programming Questions and Answers – Break and Continue – 2

«
»

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

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

advertisement

1. 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.             continue;
  9.         }
  10.     }

a) Hello is printed infinite times
b) Hello
c) Varies
d) Compile time error
View Answer

Answer: d
Explanation: None.
advertisement
advertisement

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

Participate in C Programming Certification Contest of the Month Now!
advertisement
  1.     #include <stdio.h>
  2.     void main()
  3.     {
  4.         int i = 0;
  5.         if (i == 0)
  6.         {
  7.             printf("Hello");
  8.             break;
  9.         }
  10.     }

a) Hello is printed infinite times
b) Hello
c) Varies
d) Compile time error
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 i = 0;
  5.         do
  6.         {
  7.             i++;
  8.             if (i == 2)
  9.                 continue;
  10.                 printf("In while loop ");
  11.         } while (i < 2);
  12.         printf("%d\n", i);
  13.     }

a) In while loop 2
b) In while loop in while loop 3
c) In while loop 3
d) Infinite loop
View Answer

Answer: a
Explanation: None.
advertisement

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

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         int i = 0, j = 0;
  5.         for (i; i < 2; i++){
  6.             for (j = 0; j < 3; j++)
  7.             {
  8.                 printf("1\n");
  9.                 break;
  10.             }
  11.             printf("2\n");
  12.         }
  13.         printf("after loop\n");
  14.     }

a)

   1
   2
   after loop

b)

   1
   after loop

c)

   1
   2
   1
   2
  after loop

d)

   1
   1
   2
   after loop
View Answer
Answer: c
Explanation: None.
 
 

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

  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;
  12.                     printf("In while loop\n");
  13.         }
  14.         printf("After loop\n");
  15.     }

a)

   In while loop
   After loop

b) After loop
c)

   In while loop
   In while loop
   After loop

d) In while loop
View Answer

Answer: b
Explanation: None.

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

  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.             {
  11.                case 'a':
  12.                    printf("%c ", c);
  13.                    break;
  14.                    break;
  15.             }
  16.         }
  17.         printf("after loop\n");
  18.     }

a) a after loop
b) a a after loop
c) after loop
d) error
View Answer

Answer: b
Explanation: None.

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

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         printf("before continue ");
  5.         continue;
  6.         printf("after continue\n");
  7.     }

a) Before continue after continue
b) Before continue
c) After continue
d) Compile time error
View Answer

Answer: d
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.