Search Header Logo

Looping in C

Authored by Dr. Singh

Computers

University

Used 3+ times

Looping in C
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

The C code ‘for(;;)’ represents an infinite loop. It can be terminated by ___________

a goto statement
a continue statement
a return statement

a break statement

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be printed by the given code ?

#include <stdio.h>

int main()

{ int z = 1;

while (z <= 5)

{ if (z == 3)

{ z++; }

printf("%d ", z);

z++; }
return 0; }

2 3 4 5

1 2 4 5

2 3 4 5 6
1 2 3 4 6

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

what will be printed by the following code?

#include<stdio.h>

int main()

{while(1)

{printf("Hello ");}

return 0;

}

Hello Hello Hello ... (infinitely)

Hello is printed once

Run time error

Compile time error

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

The for statement

for(expr1;expr2;expr3)

{statement;}

is equivalent to

while(expr1 == expr2)

{

statement;

expr3;

}

while(expr1 != expr2)

{

statement;

expr3;

}

expr1;

while(expr2)

{

statement;

expr3;

}

None of the above

5.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

The code:

#include<stdio.h>

int main()

{int j = 0;

while(j<3)

{j++;

printf("In the loop");}

How many times 'j' value is checked?

2
3
5
4

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

In which type of loop, the body of the loop is executed at least once

for loop
while loop

both for and while loop

do-while loop

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output?

#include<stdio.h>

int main()

{ int p=1;

while(p=8)

{ printf("Test ");

p++;}}

Prints 'Test ' followed by 'Done'
Single print of 'Test'
Infinite loop printing 'Test '
No output due to syntax error

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?