Here is a listing of C Objective Questions on “Break and Continue statements” along with answers, explanations and/or solutions:
1. Which keyword can be used for coming out of recursion?
a) break
b) return
c) exit
d) both break and return
Answer: b
Clarification: None.
2. What will be the output of the following 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
Answer: d
Clarification: None.
3. What will be the output of the following 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
Answer: d
Clarification: None.
4. The keyword ‘break’ cannot be simply used within _________
a) do-while
b) if-else
c) for
d) while
Answer: b
Clarification: None.
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
Clarification: None.
6. What will be the output of the following 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
Answer: a
Clarification: None.
7. What will be the output of the following 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
Answer: b
Clarification: None.
8. What will be the output of the following 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
Answer: c
Clarification: None.