wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Competitive Coding-I

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

What will be the output of the following C code?

#include <stdio.h>

void main()

{

int x = 5;

if (x < 1)

printf("hello");

if (x == 5)

printf("hi");

else

printf("no");

}

a)

hi

b)

hello

c)

no

d)

error

2.

What will be the output of the following C code?

#include <stdio.h>

int main()

{

int x = 0;

if (x == 1)

if (x == 0)

printf("inside if\n");

else

printf("inside else if\n");

else

printf("inside else\n");

}

a)

inside if

b)

inside else if

c)

inside else

d)

compile time error

3.

What will be the output of the following C code?

#include <stdio.h>

int main()

{

int x = 0;

if (x == 1)

if (x >= 0)

printf("true\n");

else

printf("false\n");

}

a)

Depends on the compiler

b)

No print statement

c)

True

d)

False

4.

The switch statement takes a given integer value then seeks a matching value among a number of _______ statements.

a)

break

b)

case

c)

switch

d)

goto

5.

How many loops are there in C

a)

1

b)

3

c)

2

d)

4

6.

Which of the following is an exit control statement

a)

for

b)

while

c)

do while

d)

continue

7.

The value of i after the execution of the following segment is

i = 2;

for( i=0; i>10; i=i+1);

a)

1

b)

2

c)

0

d)

11

8.

The output of the following segment is

int k, n=20;

k=(n>5?(n<=10?100:200):500);

printf("%d",n);

a)

100

b)

200

c)

300

d)

20

9.

C language developed at _____?

a)

AT & T's Bell Laboratories of USA in 1972

b)

AT & T's Bell Laboratories of USA in 1970

c)

Sun Microsystems in 1973

d)

Cambridge University in 1972

10.

which is the only function all C programs must contain?

a)

start()

b)

sys()

c)

main()

d)

scanf()

11.

Which of the following is not a correct variable type?

a)

float

b)

real

c)

int

d)

double

12.

What will be the output of the following C code?

#include <stdio.h>

int main()

{

int a = 1, b = 1, c;

c = a++ + b;

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

}

a)

a=1, b=1

b)

a=2, b=1

c)

a=1, b=2

d)

a=2, b=2

13.

What will be the output of the following C code?

#include <stdio.h>

int main()

{

int i = 0;

int j = i++ + i;

printf("%d\n", j);

}

a)

0

b)

1

c)

2

d)

compile time error

14.

What will be the output of the following C code?

#include <stdio.h>

int main()

{

int a = 1, b = 1;

switch (a)

{

case a*b:

printf("yes ");

case a-b:

printf("no\n");

break;

}

}

a)

yes

b)

no

c)

yes no

d)

compile time error

15.

Library function pow() belongs to which header file?

a)

math.h

b)

square.h

c)

stdio.h

d)

conio.h

16.

Is it possible to run program without main() function?

a)

yes

b)

no

c)

may be

17.

How many main() function we can have in our project?

a)

1

b)

2

c)

no limit

d)

depends on the program

18.

int x = 10;


int main()

{

int x = 0;

printf("%d",x);

return 0;

}

a)

10

b)

0

c)

compile error

d)

undefined

19.

What should be the output:

int main()

{

int a = 10/3;

printf("%d",a);

return 0;

}

a)

3.33

b)

3.0

c)

3

d)

0

20.

#include "stdio.h"

int main()

{

int a = 10;

printf("%d", a);

int a = 20;

printf("%d",a);

return 0;

}

a)

1020

b)

1010

c)

2020

d)

Error: Redeclaration of a