wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Day 5 condition & Loops

Total questions: 12

Worksheet time: 6mins

Name
Class
Date
1.

The continue statment cannot be used with

a)

for

b)

while

c)

do while

d)

switch

2.

Which keyword can be used for coming out of recursion?

a)

return

b)

break

c)

exit

d)

both A and B

3.

goto can be used to jump from main to within a function?

a)

True

b)

False

c)

May be

d)

Can't say

4.

Which loop is guaranteed to execute at least one time.

a)

for

b)

while

c)

do while

d)

None of the above

5.

What is the output of this program?

#include <stdio.h>

int main()

{

int i;

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

int a = i;

printf("%d", a);

}

a)

Syntax error in declaration of 'a' variable

b)

No errors, program will show the output 5

c)

Redeclaration of a in same scope throws error

d)

a is out of scope when printf is called

6.

What is the output of this program?

#include <stdio.h>

void main()

{

int a=1, b=2, c=3, d;

d = (a=c, b+=a, c=a+b+c);

printf("%d %d %d %d", d, a, b, c);

}

a)

11 3 5 11

b)

11 1 5 11

c)

11 3 2 11

d)

11 3 3 11

7.

Array is ______ datatype in C Programming language.

a)

Derivative Data Type

b)

Primitive Data Type

c)

Custom Data Type

d)

None of the above

8.

What is the output of this program?

#include <stdio.h>

int main(){

printf("%d",EOF);

return 0;

}

a)

0

b)

1

c)

-1

d)

Null

9.

What is the output of this program?

void main()

{

if(!printf(""))

printf("hello");

else

printf("world");

}

a)

hello

b)

world

c)

Compilation error

d)

None of the above

10.

What is correct about the given program?

#include <stdio.h>

int x;

void main()

{

if (x);

else

printf("Else");

}

a)

if block will be executed

b)

else block will be executed

c)

Depends on value of x since it is undeclared

d)

Compilation Error

11.

What is the output of this program?

void main()

{

int x=0;

for(;;)

{

if(x==3)

break;

printf("%d ",++x);

}

}

a)

1 2 3

b)

0 1 2 3

c)

1 2

d)

Compilation Error

12.

How many times letsfindcourse will be printed?

#include <stdio.h>

int main()

{

int i = -5;

while (i <= 5)

{

if (i >= 0)

break;

else

{

i += 1;

continue;

}

printf("letsfindcourse");

}

return 0;

}

a)

5 times

b)

10 times

c)

0 times

d)

Infinite times