wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

C Language Basics

Total questions: 26

Worksheet time: 15mins

Name
Class
Date
1.

Which header file is required to perform standard input and output opeartions

a)

math.h

b)

stdio.h

c)

input.h

d)

io.h

2.

Which of the following is correct identifier?

a)

int

b)

1ab

c)

a_123

d)

a 123

3.

what is the output of the following statement?

printf("hi\nhello\nhow\bare\ryou");

a)

hi

hello

how

are

you

b)

hi

hello

hoare

you

c)

hi

hello

youre

d)

hi

hello

youare

4.

Who is the father of C language?

a)

Dennis Ritche

b)

Charles Babbage

c)

Steve Jobs

d)

V Kohli

5.

Which of the following is not a valid C variable name?

a)

int num;

b)

float price;

c)

char a_s;

d)

int $total;

6.

The C-preprocessors are specified with _________ symbol.

a)

$

b)

#

c)

&

d)

*

7.

What is the sizeof(char) in a 32-bit C compiler?

a)

1 bit

b)

2 bits

c)

1 byte

d)

2 bytes

8.

What will be the final value of x in the following C code?

#include <stdio.h>

void main()

{

int x = 5 * 9 / 3 + 9;

}

a)

3.75

b)

24

c)

3

d)

15

9.

What will be the output of the following C code snippet?

#include <stdio.h>

void main()

{

1 < 2 ? printf("Hi"): printf("hello");

}

a)

Hi

b)

hello

c)

hi

hello

d)

none

10.

What is the size of an int data type in 64-bit compiler?

a)

4 bytes

b)

8 bytes

c)

10 bytes

d)

2 bytes

11.

What will be the output of the following C code?

#include <stdio.h>

void main()

{

int y = 3;

int x = 5 % 2 * 3 / 2;

printf("Value of x is %d", x);

}

a)

Value of x is 1

b)

Value of x is 3

c)

Value of x is 1.5

d)

Error

12.

What is the precedence of arithmetic operators (from highest to lowest)?

a)

%, *, /, +, –

b)

%, +, /, *, –

c)

+, -, %, *, /

d)

%, +, -, *, /

13.

What will be the output of the following C code?

#include <stdio.h>

int main()

{

int a = 10;

double b = 5.6;

int c;

c = a + b;

printf("%d", c);

}

a)

15.6

b)

15

c)

16

d)

10

14.

What will be the output of the following C code?

#include <stdio.h>

int main()

{

int a = 10, b = 5, c = 5;

int d;

d = a == (b + c);

printf("%d", d);

}

a)

Error

b)

1

c)

10

d)

15

15.

What will be the output of the following C code?

#include <stdio.h>

void main()

{

int x = 1, y = 0, z = 5;

int a = (x && y) || (z++);

printf("%d", z);

}

a)

error

b)

5

c)

6

d)

0

16.

Which among the following is NOT a logical opearator?

a)

&&

b)

||

c)

!

d)

!=

17.

What will be the output of the following C code?

#include <stdio.h>

void main()

{

int x = 1, z = 3;

int y = x << 3;

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

}

a)

error

b)

1

c)

8

d)

-1

18.

What will be the output of the following C code?

#include <stdio.h>

void main()

{

int h = 8;

int b = h++;

printf("%d%d\n", b, h);

}

a)

8 8

b)

8 9

c)

9 9

d)

9 8

19.

What will be the output of the following C code?

#include <stdio.h>

void main()

{

char b = 'B';

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

}

a)

65

b)

66

c)

B

d)

b

20.

What will be the output of the following C code?

#include <stdio.h>

void main()

{

char b = 'B';

printf("%c\n", b+32);

}

a)

65

b)

66

c)

B

d)

b

21.

The ______ symbol denotes decision making in flowchart?

a)

b)

c)

d)

22.

What will be the output of the following C code?

#include <stdio.h>

void main()

{

char b = 'B';

printf("%c\n", b+3);

}

a)

E

b)

e

c)

B

d)

b

23.

The ______ symbol used for input/ output operation in flowchart?

a)
b)
c)
d)
24.

What is the output of this program?

#include <stdio.h>

void main()

{

printf("hello\rworld\n");

printf("hello\b\b\bworld\n");

}

a)

hello

helloworld

b)

world

heworld

c)

world

hellworld

d)

helloworld

heworld

25.

What is the output of the following code?

void main()

{

int i=1;

i=2+2*i++;

printf("%d",i);

}

a)

2

b)

3

c)

4

d)

5

26.

What is the output of this program?

main ()

{

int i=5;

printf( "%d %d %d " , i, i<<2, i>>2);

}

a)

5 1 20

b)

5 20 1

c)

5 20 20

d)

5 1 1