C Programming Questions and Answers on Break and Continue for Freshers

https://www.computersprofessor.com/2017/11/c-programming-questions-and-answers-on_30.html
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?
#include
int main()
{
int a = 0, i = 0, b;
for (i = 0;i < 5; i++)
{
a++;
continue;
}
}
a) 2
b) 3
c) 4
d) 5
b) 3
c) 4
d) 5
Answer: d
3. What is the output of this C code?
#include
int main()
{
int a = 0, i = 0, b;
for (i = 0;i < 5; i++)
{
a++;
if (i == 3)
break;
}
}
a) 1
b) 2
c) 3
d) 4
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?
#include
void main()
{
int i = 0, j = 0;
for (i = 0;i < 5; i++)
{
for (j = 0;j < 4; j++)
{
if (i > 1)
break;
}
printf("Hi \n");
}
}
a) Hi is printed 5 times
b) Hi is printed 9 times
c) Hi is printed 7 times
d) Hi is printed 4 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?
#include
void main()
{
int i = 0;
int j = 0;
for (i = 0;i < 5; i++)
{
for (j = 0;j < 4; j++)
{
if (i > 1)
continue;
printf("Hi \n");
}
}
}
a) Hi is printed 9 times
b) Hi is printed 8 times
c) Hi is printed 7 times
d) Hi is printed 6 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?
#include
void main()
{
int i = 0;
for (i = 0;i < 5; i++)
if (i < 4)
{
printf("Hello");
break;
}
}
a) Hello is printed 5 times
b) Hello is printed 4 times
c) Hello
d) Hello is printed 3 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?
#include
void main()
{
int i = 0;
if (i == 0)
{
printf("Hello");
continue;
}
}
a) Hello is printed infinite times
b) Hello
c) Varies
d) Compile time error
b) Hello
c) Varies
d) Compile time error
Answer: d
10. What is the output of this C code?
#include
void main()
{
int i = 0;
if (i == 0)
{
printf("Hello");
break;
}
}
a) Hello is printed infinite times
b) Hello
c) Varies
d) Compile time error
b) Hello
c) Varies
d) Compile time error
Answer: d
11. What is the output of this C code?
#include
int main()
{
int i = 0;
do
{
i++;
if (i == 2)
continue;
printf("In while loop ");
} while (i < 2);
printf("%d\n", i);
}
a) In while loop 2
b) In while loop in while loop 3
c) In while loop 3
d) Infinite loop
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?
#include
int main()
{
int i = 0, j = 0;
for (i; i < 2; i++){
for (j = 0; j < 3; j++){
printf("1\n");
break;
}
printf("2\n");
}
printf("after loop\n");
}
a) 1
2
after loop
b) 1
after loop
c) 1
2
1
2
after loop
d) 1
1
2
after loop
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?
#include
int main()
{
int i = 0;
while (i < 2)
{
if (i == 1)
break;
i++;
if (i == 1)
continue;
printf("In while loop\n");
}
printf("After loop\n");
}
a) In while loop
After loop
b) After loop
c) In while loop
In while loop
After loop
d) 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?
#include
int main()
{
int i = 0;
char c = 'a';
while (i < 2){
i++;
switch (c) {
case 'a':
printf("%c ", c);
break;
break;
}
}
printf("after loop\n");
}
a) a after loop
b) a a after loop
c) after loop
d) None of the mentioned
b) a a after loop
c) after loop
d) None of the mentioned
Answer: b
15. What is the output of this C code?
#include
int main()
{
printf("before continue ");
continue;
printf("after continue\n");
}
a) Before continue after continue
b) Before continue
c) After continue
d) Compile time error
b) Before continue
c) After continue
d) Compile time error
Answer: d