C Loops control Questions 2

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
What is the expected output of the following program ?

#include <stdio.h> int main() { int i = 0; switch (i) { case '0': printf("This "); case '1': printf("will "); case '2': printf("probably "); case '3': printf("be "); case '4': printf("printed "); default: printf("or will it ?"); } return 0; }

This will probably be printed

This will probably be printed

This will probably be printed or will it ?

This will probably be printed or will it ?

This

This

or will it ?

or will it ?

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

Please login to submit your explanation

Start

Question 2

Time: 00:00:00
Select the correct option for the output of the following C code.

#include <stdio.h> int main() { int i = 5; switch (i) { case 5+5: printf("Text1"); break; case 5: printf("Text2"); break; case 2+3: printf("Text3"); break; default: printf("Text4"); } return 0; }

Text 1 Text 1

Text 1 Text 1

Text 2

Text 2

Text 1 Text 1 Text 2 Text 3

Text 1 Text 1 Text 2 Text 3

Text 3

Text 3

Compilation error.

Compilation error.

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 printed on the execution of the following program?

#include <stdio.h> int main() { int i = 32; int j; for (j=1 ; i ; j++,i >>= 1) printf("%dPrepSter ",j); return 0; }

Infinite loop with %dPrepSter

Infinite loop with %dPrepSter

1PrepSter 2PrepSter 3PrepSter 4PrepSter 5PrepSter

1PrepSter 2PrepSter 3PrepSter 4PrepSter 5PrepSter

1PrepSter 2PrepSter 3PrepSter 4PrepSter 5PrepSter 6PrepSter

1PrepSter 2PrepSter 3PrepSter 4PrepSter 5PrepSter 6PrepSter

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 by the program given below ?

#include <stdio.h> int main() { int i; if (printf("0")) i = 2; else if (printf("9")) i = 2; else i = 4; printf("%d", i); return 0; }

029

029

40

40

02

02

4

4

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

Please login to submit your explanation

Start

Question 5

Time: 00:00:00
Choose the correct output for the following code.

#include <stdio.h> int i; int main() { if (i) printf("TEXT1"); else printf("TEXT2"); return 0; }

TEXT1

TEXT1

TEXT2

TEXT2

(null)

(null)

Compilation error.

Compilation error.

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

Please login to submit your explanation

Start

Question 6

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

#include <stdio.h> int main() { int i,j; for(;i<3;i++) { for(j=0;j<2;j++) { printf("%d%d ",i,j); } } return 0; }

Compilation error.

Compilation error.

00 10 01 11 02 12

00 10 01 11 02 12

00 01 11 01 20 22

00 01 11 01 20 22

00 01 10 11 20 21

00 01 10 11 20 21

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

Please login to submit your explanation

Start

Question 7

Time: 00:00:00
Select the correct output for the given program.

#include <stdio.h> int main() { int i,j; for(;i<3;i++) { for(j=5;j>2;j--) { printf("%d%d ",i,j); } } return 0; }

05 04 03 15 14 13 25 24 23

05 04 03 15 14 13 25 24 23

Falls out of loop, nothing is printed.

Falls out of loop, nothing is printed.

01 02 03 11 12 13 21 22 23

01 02 03 11 12 13 21 22 23

05 04 15 14 25 24 35 34

05 04 15 14 25 24 35 34

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 correct output for the following code ?

# include <stdio.h> int main() { int i = 0; for (i=0; i<20;) { switch(i) { case 0: i += 5; break; case 10: i += 9; break; case 5: i += 5; break; default: i += 4; break; } printf("%d ", i); } return 0; }

5

5

5 10 19 23

5 10 19 23

4

4

5 10 19

5 10 19

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

Please login to submit your explanation

Start

Question 9

Time: 00:00:00
In of the following is we form a series of loop, which some times help to reduce complexity.

Loop jamming.

Loop jamming.

Strength reduction.

Strength reduction.

Loop concatenation

Loop concatenation

Loop unrolling.

Loop unrolling.

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

Please login to submit your explanation

Start

Question 10

Time: 00:00:00
Which of the following is used to terminate program execution and to return to the operating system ?

terminate()

terminate()

exit()

exit()

abort()

abort()

assert()

assert()

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!"]
Hey ! Follow us on G+