C Programming Questions and Answers on Break and Continue for Freshers

1. Which keyword can be used for coming out of recursion?

a) break
b) return
c) exit
d) Both break and return
Answer: b
2. What is the output of this C code?

  1.     #include 
  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
Answer: d
3. What is the output of this C code?

  1.     #include 
  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
Answer: d
4. The keyword ‘break’ cannot be simply used within:

a) do-while
b) if-else
c) for
d) while
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 is the output of this C code?

  1.     #include 
  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
Answer: a
7. What is the output of this C code?

  1.     #include 
  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
Answer: b
8. What is the output of this C code?

  1.     #include 
  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
Answer: c
9. What is the output of this C code?

  1.     #include 
  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
Answer: d
10. What is the output of this C code?

  1.     #include 
  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
Answer: d
11. What is the output of this C code?

  1.     #include 
  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
Answer: a
12. What is the output of this C code?

  1.     #include 
  2.     int main()
  3.     {
  4.         int i = 0, j = 0;
  5.         for (i; i < 2; i++){
  6.             for (j = 0; j < 3; j++){
  7.                 printf("1\n");
  8.                 break;
  9.             }
  10.             printf("2\n");
  11.         }
  12.         printf("after loop\n");
  13.     }
a) 1
    2
    after loop
b) 1
    after loop
c) 1
    2
    1
    2
    after loop
d) 1
    1
    2
    after loop
Answer: c
13. What is the output of this C code?

  1.     #include 
  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
Answer: b
14. What is the output of this C code?

  1.     #include 
  2.     int main()
  3.     {
  4.         int i = 0;
  5.         char c = 'a';
  6.         while (i < 2){
  7.             i++;
  8.             switch (c) {
  9.             case 'a':
  10.                 printf("%c ", c);
  11.                 break;
  12.                 break;
  13.             }
  14.         }
  15.         printf("after loop\n");
  16.     }
a) a after loop
b) a a after loop
c) after loop
d) None of the mentioned
Answer: b
15. What is the output of this C code?

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

Related

HTML Multiple Choice Questions & Answers on Choosing Editors and IDEs for Freshers

1. Which of the following is not an IDE a) BlueGriffon 1.5.2b) Aptana studio 3c) TextEdit(Mac)d) Dreamweaver Answer: c Explanation: TextEdit is a highly versatile word processor included with OS ...

CSS Multiple Choice Questions & Answers on CSS Functions for Freshers

1. Which of the following element is used by the filter property to blur the images? a) opaque()b) scatter()c) blur()d) all of the mentioned Answer: c Explanation: Blurs an element, for use by th...

Java Multiple Choice Questions & Answers on Bitwise Operators for Freshers

1. Which of these is not a bitwise operator? a) &b) &=c) |=d) <= Answer:d Explanation: <= is a relational operator. 2. Which operator is used to invert all the digits in binary rep...

Post a Comment

emo-but-icon
:noprob:
:smile:
:shy:
:trope:
:sneered:
:happy:
:escort:
:rapt:
:love:
:heart:
:angry:
:hate:
:sad:
:sigh:
:disappointed:
:cry:
:fear:
:surprise:
:unbelieve:
:shit:
:like:
:dislike:
:clap:
:cuff:
:fist:
:ok:
:file:
:link:
:place:
:contact:

item