wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

CPR _Chapter2 _Onlinequiz

Total questions: 15

Worksheet time: 22mins

Name
Class
Date
1.

What will be the output of following program ?

#include <stdio.h>

void main()

{

int i=1;

do

{

printf("%d,",i);

i=i+1;

}while(i>=10);

printf("\nAfter loop i=%d",i);

printf("\n");

}

a)

After loop i=1

b)

1

After loop i=2

c)

After loop i=2

d)

None of the above

2.

Choose a right C Statement.

a)

Loops or Repetition block executes a group of statements repeatedly.

b)

Loop is usually executed as long as a condition is met.

c)

Loops usually take advantage of Loop Counter

d)

All the above.

3.

What is the output of C Program.?

int main()

{

int a=25;

while(a <= 27)

{

printf("%d ", a);

a++;

}


return 0;

}

a)

25 25 25

b)

25 26 27

c)

27 27 27

d)

Compiler error

4.

What is the output of C Program.?


int main()

{

int k;

for(k=1; k <= 5; k++);

{

printf("%d ", k);

}


return 0;

}

a)

1 2 3 4 5

b)

1 2 3 4

c)

5

d)

6

5.

What is the way to suddenly come out of or Quit any Loop in C Language.?

a)

continue; statement

b)

break; statement

c)

leave; statement

d)

quit; statement

6.

Choose a correct C for loop syntax.

a)

for(initialization; condition; increment operation)

{

//statements

}

b)

for(declaration; condition; increment operation)

{

//statements

}

c)

for(declaration; increment operation; condition)

{

//statements

}

d)

for(initialization; condition; increment operation;)

{

//statements

}

7.

What is the output of C Program with switch statement.?


int main()

{

int a=3;

switch(a)

{

case 2: printf("ZERO "); break;


case default: printf("RABBIT ");

}

}

a)

RABBIT

b)

ZERO RABBIT

c)

No output

d)

Compiler error

8.

What is the output of C Program with switch statement or block.?

int main()

{

static int a=5;

switch(a)

{

case 0: printf("ZERO ");break;

case 5: printf("FIVE ");break;

case 10: printf("DEER ");

}

printf("LION");

}

a)

ZERO FIVE DEER LION

b)

FIVE DEER LION

c)

FIVE LION

d)

Compiler error

9.

#include <stdio.h>

void main()

{

int x = 0;

if (x == 0)

printf("hi");

else

printf("how are u");

printf("hello");

}

a)

hi

b)

how are u

c)

hello

d)

hihello

10.

What is the output of C Program.?


int main()

{

int a=9;

if(a==9);

{

printf("Ostrich\n");

}

elseif(a==8)

{

printf("Eggs\n");

}

else

printf("White");


return 0;

}

a)

White

b)

Ostrich

c)

White

d)

compiler error

11.

How many choices are possible when using a single if-else statement?

a)

1

b)

2

c)

3

d)

4

12.

A "switch" statement is used to

a)

Switch between functions in a program

b)

witch from one variable to another variable

c)

To choose from multiple possibilities which may arise due to different values of a single variable

d)

.All of above

13.

Loops in C Language are implemented using.?

a)

While

b)

For

c)

Do While

d)

All the above

14.

Choose a correct syntax of if -else Conditional Statement.

a)

if( condition )

{

//statements;

}

b)

if( condition )

{

//statements;

}

else

{

//statements;

}

c)

if( condition1 )

{

//statements;

}

else if( condition2)

{

//statements;

}

else

{

//statements;

}

d)

All the above.

15.

Which loop is most suitable to first perform the operation and then test the condition?

a)

for loop

b)

while loop

c)

do-while loop

d)

none of the mentioned