wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Quiz on Basics of C

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

What will be the output of the following C code?

#include <stdio.h>

void main()

{ int x = 5;

if (true);

printf("hello");

}

a)

a) It will display hello

b)

b) It will throw an error

c)

c) Nothing will be displayed

d)

d) Compiler dependent

2.

#include <stdio.h>

int x;

void main()

{

if (x)

printf("hi");

else

printf("how are u");

}

a)

a) hi

b)

b) how are you

c)

c) compile time error

d)

d) error

3.

What does the following code fragment write to the monitor?


int sum = 14;

if ( sum < 20 )

System.out.print("Under ");

else

System.out.print("Over ");

System.out.println("the limit.");

a)

Under

b)

Over.

c)

. Under the limit

d)

Over the limit.

4.

int main()

{

int a = 25%10;

printf("%d", a);


return 0;

}

a)

5

b)

2

c)

2.5

d)

5.5

5.

!= is the example of ____________________ operator.

a)

Relational

b)

Logical

c)

Assignment

d)

Conditional

6.

#include <stdio.h>


void main()

{


int x = 5 * 9 / 3 + 9;


}

a)

24

b)

3

c)

23

d)

4

7.

int x = 15;

x=+5;

printf("x value is: %d",x);

a)

Error

b)

x value is: 20

c)

x value is: 15

d)

None of these

8.

int x = 15, y=10;

if(x>20 && y<=10)

printf("Condition Satisfied");

else

printf("Condition not satisfied");

a)

Error

b)

Condition Satisfied

c)

Condition not Satisfied

d)

None of these

9.

1011 & 0111

a)

1000

b)

0011

c)

1011

d)

None of these

10.

Which header file can be used to define input/output function prototypes and macros?

a)

- math.h

b)

- memory.h

c)

- stdio.h

d)

- dos.h