wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

c programming

Total questions: 30

Worksheet time: 15mins

Name
Class
Date
1.

What is the 16-bit compiler allowable range for integer constants?

a)

-3.4e38 to 3.4e38

b)

-32767 to 32768

c)

-32668 to 32667

d)

-32768 to 32767

2.

Directives are translated by the

a)

Pre-processor

b)

Compiler

c)

Linker

d)

Editor

3.

What is the result after execution of the following code if a is 10, b is 5, and c is 10?

if ((a > b) && (a <= c))

a = a + 1;

else

c = c+1;

a)

a = 10, c = 10

b)

a = 11, c = 10

c)

a = 10, c = 11

d)

a = 11, c = 11

4.

What will happen when the following code is executed?

void main()

{

printf("MIET");

main();

}

a)

Wrong statement

b)

It will keep on printing MIET

c)

It will print MIET once

d)

None of these

5.

What will the result of num1 variable after execution of the following statements?

int j = 1, num1 = 4;

while (++j <= 10)

{

num1++;

}

a)

11

b)

12

c)

13

d)

14

6.

What will be the output of the following code?

#include <stdio.h>

int main()

{

int *ptr, a = 10;

ptr = &a;

*ptr += 1;

printf("%d,%d/n", *ptr, a);

}

a)

10, 10

b)

10, 11

c)

11, 10

d)

11, 11

7.

Give the following declarations and an assignment statement. Which one is equivalent to the expression str [4]?

char str[80];

char * p;

p = str;

a)

p + 4

b)

*p + 4

c)

*(p + 4)

d)

p[3]

8.

Find the output in following code

int main ()

{

int a,b ;

a= b= 4 ;

b =a++;

Printf ( " %d %d %d %d", a++, --b, ++a, b--);

}

a)

5 3 73

b)

5 4 5 3

c)

6 2 6 4

d)

Syntax Error

9.

Find error/ output in following code

How many times " placement Questions" will print.

int main

{

int x;

for ( x=1;x <=10; x++)

{

if ( x < 5)

Continue;

else

break;

Printf (" placement Question ");

{

return 0;

}

a)

Infinite time

b)

11 times

c)

0 time

d)

10 times

10.

Find error/ output in following code

int main ()

{

int a = 10, b = 25;

a = b++ + a++;

b= ++b + ++a;

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

}

a)

36 64

b)

35 62

c)

36 63

d)

30 28

11.

Find error/output in following code

int main ()

{

int m = -10,n =20;

n = ( m < 0) ? 0 : 1;

printf ( " %d %d ", m,n ) ;

}

a)

-10 0

b)

10 20

c)

20 -10

d)

0 1

12.

Find error/ output in following code

int main ()

{

int i = 0;

for ( ; ;)

printf ( "%d", i) ;

return 0;

}

a)

O times

b)

Infinite times

c)

10 times

d)

1 times

13.

Find Error/ output in following code

Void main ()

{

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

Char d = 0;

if (a,b,c,d)

{

printf ( " EXAM") ;

}

}

a)

No output and No error

b)

EXAM

c)

Runtime Error

d)

Compile time error

14.

select the correct syntax to read a variable named num of type integer from user

a)

scanf("%d",num);

b)

scanf("%d",&num);

c)

scanf("%d,&num");

d)

scanf("%d,num");

15.

Which of the following is not logical operator?

a)

&

b)

||

c)

!

d)

&&

16.

#include <stdio.h>

int main(){

int x= 5%2 *3/2;

printf("%d",x);

return 0;

}

a)

1

b)

2

c)

3

d)

99

17.

What is the Output:

int a=5;

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

a)

5

b)

6

c)

7

d)

4

18.

What is the Output :

void main()

{

int a=5,b=6,k;

k=b>a?b:a;

printf("%d",k);

}

a)

5

b)

6

c)

11

d)

Error

19.

There are ___ storage classes in C

a)

2

b)

4

c)

6

d)

8

20.

Programming Language C has only --------- Keywords

a)

32

b)

31

c)

33

d)

34

21.

1 GB is equal to ------------

a)

1024KB

b)

1024 Byte

c)

1024MB

d)

1024 nano

22.

The correct order of evaluation for the expression “z = x + y * z / 4 % 2 – 1”

a)

* / % = + -

b)

/ * % - + =

c)

- + = * % /

d)

* / % + - =

23.

A pointer pointing to a memory location of the variable even after deletion of the variable is known as _____

a)

far pointer

b)

dangling pointer

c)

null pointer

d)

void pointer

24.

What is the output of this statement "printf("%d", (a++))"?

a)

The value of (a + 1)

b)

The current value of a

c)

Error message

d)

Garbage

25.

The user can also write one or more statements in one line by separating semicolon (;)

a)

True

b)

False

26.

2. Which statement best describes logic errors?

a)

An error in a program that causes it to produce incorrect ouputs but not a crash.

b)

An error in a program that causes it to crash.

c)

An error in the program caused by mis-spelt instructions.

d)

An error in a program caused by hardware failure.

27.

12.Is it possible to return two values by any function?

a)

yes

b)

no

28.

14.what will be the output?

#include <stdio.h>


void decrement();


int main()

{

decrement();

decrement();

decrement();

return 0;

}


void decrement()

{

int i = 5;

printf("%d",i);

i--;

}

a)

A) 555

b)

(B) 543

c)

(C) 545

d)

(D) 544

29.

15.Choose the correct answer.

a)

a) Recursion is always better than iteration.

b)

b) Recursion uses more memory compared to iteration.

c)

c) Recursion uses less memory compared to iteration.

d)

d) Iterative function is always better and simpler to write than recursion.

30.

Given two literals 0x001B and 033. What are these equal to?

a)

21 and 23

b)

27 and 33

c)

33 and 33

d)

27 and 27