C Loops control Questions 3

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 will be the output of the given program ?

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

1234

1234

124

124

1245

1245

12345

12345

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

Please login to submit your explanation

Start

Question 2

Time: 00:00:00
What is the expected output of the C code below ?

#include <stdio.h> int main() { char ch = 'a'; switch (ch) { case 'a' || 1: printf("Prep"); case 'b' || 2: printf("Insta"); break; default: printf("GeeksQuiz"); } return 0; }

Prep

Prep

Prep Insta

Prep Insta

Run time error

Run time error

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

#include <stdio.h> int main() { int arr[] = {10, 20, 30}; int ch=10; switch (ch) { case arr[0]: printf("Prep"); case arr[1]: printf("Insta "); default: printf("PrepSter"); } return 0; }

Prep

Prep

PrepInsta PrepSter

PrepInsta PrepSter

Compilation error

Compilation error

PrepSter

PrepSter

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 the output of the code given below ?

#include<stdio.h> int main() { int pre = -5; while (pre <= 5) { if (pre >= 0) break; else { pre++; continue; } printf("PrepInsta "); } return 0; }

PrepInsta PrepInsta PrepInsta PrepInsta PrepInsta PrepInsta

PrepInsta PrepInsta PrepInsta PrepInsta PrepInsta PrepInsta

Run time error.

Run time error.

PrepInsta PrepInsta PrepInsta PrepInsta PrepInsta

PrepInsta PrepInsta PrepInsta PrepInsta PrepInsta

(null)

(null)

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 will be printed after the execution of the following program ?

#include <stdio.h> int main() { int var = 5; if (var == 7); var = 0; if (var == 5) var++; else var += 8; printf("%d", var); return 0; }

8

8

5

5

6

6

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
Select the correct output for the following program.

#include <stdio.h> int main() { int val = 5; while (val--) { int val = 100; val--; printf("%d ", val); } return 0; }

99 will be printed 99 times

99 will be printed 99 times

99 99 99 99 99

99 99 99 99 99

99 98 97 96 95

99 98 97 96 95

99 be be printed infinitely

99 be be printed infinitely

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 value can not be used to represent a case label ?

 

char

char

enum

enum

float

float

int

int

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 will the pried upon the execution of the given program ?

#include <stdio.h> int main() { char name='a'; switch ('name') { case 'a': printf("Text1 "); case 'b': printf("Text2 "); default: printf("Text3 "); } return 0; }

Text1 Text2 Text3

Text1 Text2 Text3

Text1

Text1

Text3

Text3

Compilation error.

Compilation error.

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

Please login to submit your explanation

Start

Question 9

Time: 00:00:00
What will be printed after the execution of the given code ?

#include <stdio.h> int main() { int i = 3; switch(i) { printf("Madness? "); case 1: printf("This"); break; case 2: printf("is "); break; defau1t: printf("Sparta !"); } return 0; }

Madness? Sparta

Madness? Sparta

Madness?

Madness?

Sparta !

Sparta !

Madness? This is Sparta !

Madness? This is Sparta !

(null)

(null)

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 the output of the following c program ?

#include <stdio.h> int main() { int a,p,q,r; p=4; q=7; r=5; a = ( p> q ) ? (( p > r ) ? p : r) : (( q > r ) ? q : r ); printf("%d",a); return 0; }

7

7

Compilation error.

Compilation error.

5

5

4

4

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!"]