C Loops control Questions

Hello PrepSter,

If you find any errors in the quiz below kindly comment in the comment section and we will make it our priority to fix it.

Also if you have a better of the solution to the questions, please do comment them below and if we find it better than ours, we will post it in our website.

Question 1

Time: 00:00:00
Find the correct output of the following code.

#include<stdio.h> int main() { int a = 5; switch(a) { default: a = 4; case 5: a = a+1; case 6: a--; case 1: a = a-1; } printf("%d", a); return 0; }

5

5

6

6

4

4

None of the above.

None of the above.

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 2

Time: 00:00:00
Assuming i has already been initialized which is the following "for loops" will be complied successfully?

1 for (i < 10; i = 0 ; i++)

2 for (i < 10; i++ ; i = 0)

3 for (i = 0; i < 10 ; i++)

4 for (i = 0; i++ ; i < 10)

5 for (i++; i = 0 ; i < 10)

6 for (i++; i < 0 ; i = 10)

Only 3 would be compiled successfully

Only 3 would be compiled successfully

Only 3 and 4 will be complied successfully but the functioning of 4 will be weird.

Only 3 and 4 will be complied successfully but the functioning of 4 will be weird.

All will be compiled expect 5 and 6

All will be compiled expect 5 and 6

All the loops will get complied successfully although their functioning might be conventional.

All the loops will get complied successfully although their functioning might be conventional.

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 3

Time: 00:00:00
What will be the output of the given program.

#include "stdio.h" int main() { int i = 1, j; for ( ; ; ) { if (i) j = --i; if (j < 10) printf("PrepSter", j++); else break; } return 0; }

It will print PrepSter 11 times.

It will print PrepSter 11 times.

It will print PrepSter infinite times.

It will print PrepSter infinite times.

It will print PrepSter 10 times.

It will print PrepSter 10 times.

It will print PrepSter 9 times.

It will print PrepSter 9 times.

Compilation error

Compilation error

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 4

Time: 00:00:00
What will be printed at the execution of the program?

#include<stdio.h> int main() { int j = 0; for ( ; j < 15 ; ) { if (j < 10) printf("Prep", j++); else continue; printf("%dSters ",j); } return 0; }

PrepSter will be printed 9 times followed by a Ster

PrepSter will be printed 9 times followed by a Ster

Prep will be printed 10 times followed by 5 times Ster

Prep will be printed 10 times followed by 5 times Ster

PrepSter will be printed 10 times followed by 5 times Ster

PrepSter will be printed 10 times followed by 5 times Ster

PrepSter will be printed 10 times followed by 5 times Ster

PrepSter will be printed 10 times followed by 5 times Ster

PrepSter will be printed 10 times.

PrepSter will be printed 10 times.

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 5

Time: 00:00:00
What type of variable can be passed in the control expression given below ?

switch(a);

a can only be of int type.

a can only be of int type.

a can be of any type except boolean.

a can be of any type except boolean.

a can only be int or char type.

a can only be int or char type.

a can also be null value.

a can also be null value.

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 6

Time: 00:00:00
Which is the following best representation for about break and continue?

break” and “continue” can be used in “for”, “while” and “do-while” loop. But only “break” can be used in “switch”.

break” and “continue” can be used in “for”, “while” and “do-while” loop. But only “break” can be used in “switch”.

“break” and “continue” can be used in “for”, “while”, “do-while” loop and “switch”.

“break” and “continue” can be used in “for”, “while”, “do-while” loop and “switch”.

“break” can be used in “for”, “while” and “do-while” whereas "continue" can be used for "while" and "switch"

“break” can be used in “for”, “while” and “do-while” whereas "continue" can be used for "while" and "switch"

break” and “continue” can be used in “for”, “while” and “do-while” loop. Besides, “continue” and “break” can be used in “switch” and “if-else.

break” and “continue” can be used in “for”, “while” and “do-while” loop. Besides, “continue” and “break” can be used in “switch” and “if-else.

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 7

Time: 00:00:00
Which is the best placement site in the code below ?

#include<stdio.h> int main() { int i = 0; for (printf("The "); i < 2 && printf("Best "); ++i && printf("Placement ")) { printf("Site "); } return 0; }

The Best Site Placement Best Site Placement

The Best Site Placement Best Site Placement

Site The Best Placement Site The Best Placement

Site The Best Placement Site The Best Placement

The Best Placement Site The Best Placement Site

The Best Placement Site The Best Placement Site

Compilation error.

Compilation error.

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 8

Time: 00:00:00
What is the output of the following program ?

#include<stdio.h> int main() { char key = 'A'; switch (key) { case 'A' : printf ("Kame") ; case 'B' : printf ("Hame") ; case 'C' : case 'D' : case 'E' : default: printf ("Haa") ; } return 0; }

Kame Hame

Kame Hame

Kame Hame Haa

Kame Hame Haa

Haa

Haa

KameHameHaa

KameHameHaa

Kame

Kame

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 9

Time: 00:00:00
Select the correct output of the following program.

#include <stdio.h> int main() { int i; for (i = 11; i != 100; i += 10) printf(" PrepSter "); return 0; }

PrepSter printed 10 times.

PrepSter printed 10 times.

PrepSter printed infinite times.

PrepSter printed infinite times.

PrepSter printed 99 times.

PrepSter printed 99 times.

PrepSter printed 9 times.

PrepSter printed 9 times.

Faulty condition statement. Compilation Error

Faulty condition statement. Compilation Error

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 10

Time: 00:00:00
What will be the output of the following C program?

#include <stdio.h> int main() { int i; for (i = 10; i != 100; i += 10) printf(" PrepSter "); return 0; }

PrepSter will be printed 9 times

PrepSter will be printed 9 times

PrepSter will be printed 10 times

PrepSter will be printed 10 times

PrepSter will be printed infinite times

PrepSter will be printed infinite times

PrepSter will be printed 11 times

PrepSter will be printed 11 times

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

["0","40","60","80","100"]
["Need more practice!","Keep trying!","Not bad!","Good work!","Perfect!"]