wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

C second module quiz

Total questions: 25

Worksheet time: 4mins

Name
Class
Date
1.

Which of the following is conditional statement in C

a)

if

b)

int

c)

printf

d)

scanf

2.

a=4;

if(a%2==0)

printf("%d is even",a);

else

printf("%d is odd",a);

Write output of the above code

a)

4 is even

b)

a is even

c)

4 is odd

d)

a is odd

3.

switch(expression)

{    

case value1:    

 //code to be executed;  break;  //optional  

case value2:  

//code to be executed;break;  //optional  

…..    

…… 

default:     

//code to be executed if all cases are not matched;    

}    

The above code is syntax of switch statement.True or false

a)

False

b)

True

4.

..................... is an alternative to mulifiple if else if statement

a)

for

b)

if else

c)

do while

d)

switch

5.

This is flowchart of

a)

if

b)

if else

c)

switch

d)

for

6.

.................. is an entry controlled loop

a)

while

b)

do while

c)

switch

7.

................. is an exit controlled loop

a)

while

b)

do while

c)

for

d)

switch

8.

for ( initialization; condition; update)

    {

  statement(s);

  }

This syntax is correct. True or false

a)

False

b)

True

9.

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

{

printf("%d", i);

}

How many times the above code executed?

a)

0

b)

2

c)

5

d)

4

10.

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

{

printf("%d\t", i);

}

What is the output of above code

a)

0

b)

0 1 2

c)

0 1 2 3 4

d)

0 1 2 3 4 5

11.

Syntax of while loop

a)

while(condition);

{

statements;

}

b)

while(condition)

{;

statements;

}

c)

while(condition)

{

statements;

}

d)

while(condition)

{

statements;

};

12.

This is the flowchart of ...... statement

a)

while

b)

do while

c)

for

13.

................... is an unconditional control statement

a)

if

b)

if else

c)

switch

d)

break

14.

................... is a group of elements of same data type

a)

while

b)

do while

c)

for

d)

array

15.

How to declare  one dimensional array

a)

int a;

b)

int a(50);

c)

int a[50];

d)

int a{50};

16.

In general one dimensional array element is accessed by ..........

a)

a(i)

b)

a[i]

c)

a{i}

d)

a*i

17.

Array is usually processed with ............ loops

a)

for

b)

while

c)

do while

d)

switch

18.

How many for loops are required to input one dimensional array

a)

0

b)

1

c)

2

d)

3

19.

How many for loops are required to input two dimensional array elements

a)

0

b)

1

c)

2

d)

3

20.

          for(i=1;i<=3;i++)

            {

   for(j=1;j<=i;j++)

            {

  printf(“1 \t");

  }

  printf(“\n”);

  }11

Write output of above code

a)

1

b)

1

1 1

c)

1

1 1

1 1 1

d)

1 1

21.

Two dimensional array elements are accessed by ..................

a)

a

b)

a[i]

c)

a[i][j]

d)

a(i)(j)

22.

How many locations are created using this statement

int a[50];

a)

10

b)

20

c)

40

d)

50

23.

How many locations are created using this statement

int a[20][20];

a)

20

b)

30

c)

40

d)

50

24.

To input 5 numbers, which code is used

a)

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

{

scanf("%d",a[i]);

}

b)

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

{

printf("%d",a[i]);

}

c)

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

{

scanf("%d",a*i);

}

25.

To output 5 numbers, which code is used

a)

printf("d",i)

b)

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

printf("%d",a[i]);

c)

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

scanf("%d",a[i]);