Computer StudyMCQ Computer ScienceQuiz Computer ScienceUGC NET

C Programming Questions and Answers – Break and Continue

C Programming Questions and Answers – Break and Continue

 

1.Which keyword can be used for coming out of recursion?

a) break

b) return

c) exit

d) Both (a) and (b)

View Answer

Answer:b

 

2.What is the output of this C code?

 

#include <stdio.h>

int main()

{

int a = 0, i = 0, b;

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

{

a++;

continue;

}

}

a) 2

b) 3

c) 4

d) 5

View Answer

Answer:d

 

3.What is the output of this C code?

 

#include <stdio.h>

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

View Answer

Answer:d

 

4.The keyword ‘break’ cannot be simply used within:

a) do-while

b) if-else

c) for

d) while

View Answer

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

View Answer

Answer:b

 

6.What is the output of this C code?

 

#include <stdio.h>

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

View Answer

Answer:a

 

7.What is the output of this C code?

 

#include <stdio.h>

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

View Answer

Answer:b

 

8.What is the output of this C code?

 

#include <stdio.h>

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

View Answer

Answer:c

 

9.What is the output of this C code?

 

#include <stdio.h>

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

View Answer

Answer:d

 

10.What is the output of this C code?

 

#include <stdio.h>

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

View Answer

Answer:d

 

11.What is the output of this C code?

 

#include <stdio.h>

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

View Answer

Answer:a

 

12.What is the output of this C code?

 

#include <stdio.h>

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

View Answer

Answer:c

 

13.What is the output of this C code?

 

#include <stdio.h>

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

View Answer

Answer:b

 

14.What is the output of this C code?

 

#include <stdio.h>

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

View Answer

Answer:b

 

15.What is the output of this C code?

 

#include <stdio.h>

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

View Answer

Answer:d

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Check Also
Close
Back to top button