wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

C PROGRAMMING

Total questions: 25

Worksheet time: 50mins

Name
Class
Date
1.
How would you round off a value from 1.66 to 2.0?
a)
ceil(1.66)
b)
floor(1.66)
c)
roundup(1.66)
d)
roundto(1.66)
2.
Point out the error in the following program 
a)
No error
b)
display() doesn't get invoked
c)
display() is called before it is defined
d)
None of these
3.
In which order do the following gets evaluated
1.Relational
2.Arithmetic
3.Logical
4.Assignment
a)
2134
b)
1234
c)
4321
d)
3214
4.
What will be the output of the program?
a)
Hello
b)
Hi Hello
c)
No output
d)
Infinite loop
5.
How will you print \n on the screen?
a)
printf("\n");
b)
echo "\\n";
c)
printf('\n');
d)
printf("\\n");
6.
What function should be used to free the memory allocated by calloc() ?
a)
dealloc();
b)
malloc(variable_name, 0)
c)
free();
d)
memalloc(variable_name, 0)
7.
A good algorithm must be: 
a)
replacable
b)
simple 
c)
open-ended
d)
detailed
8.

What is the output of C Program.?

int main()

{

int a=5;

while(a >= 3);

{

printf("RABBIT\n");

break;

}

printf("GREEN");

return 0;

}

a)

GREEN

b)

RABBIT GREEN

c)

RABBIT is printed infinite times

d)

None of the above

9.

What is the output of C Program.?

int main()

{

int a=25;

while(a <= 27)

{

printf("%d ", a);

a++;

}

return 0;

}

a)

25 25 25

b)

25 26 27

c)

27 27 27

d)

Compiler error

10.

What is the output of C Program.?

int main()

{

int a=32;

do

{

printf("%d ", a);

a++;

}

while(a <= 30);

return 0;

}

a)

32

b)

33

c)

30

d)

No Output

11.

#include<stdio.h>

int main()

{

int a=2,b=7,c=10;

c=a==b;

printf("%d",c);

}

a)

0

b)

7

c)

2

d)

Compilation error

12.

What will be the output of given program ?


#include<stdio.h>

main()

{

int y=10;

int z=y+(y==10);

printf(“%d”,z);

}

a)

10

b)

11

c)

20

d)

Compiler error

13.

In the following loop construct, which one is executed only once always.

for(exp1; exp2; exp3)

a)

exp1

b)

exp3

c)

exp1 and exp3

d)

exp1,exp2 and exp3

14.

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

15.

What does the following code fragment write to the monitor?

a)

Under

b)

Over

c)

Under the limit

d)

Over the limit

16.

An opertor used to check a condition and select a value depending on the value of the condition is called

a)

Logical operator

b)

Decrement operator

c)

Conditional or Ternary operator

d)

Bitwise operator

17.

What value will be stored in z if the following code is executed?

x = 5 , y = -10, a = 4, b = 2;

z = x+++++y * b/a;

a)

-2

b)

0

c)

1

d)

2

18.

What value will be stored in z if the following code is executed?

x = 5 , y = -10, a = 4, b = 2;

z = x+++++y * b/a;

a)

-2

b)

0

c)

1

d)

2

19.

#include <stdio.h>

void main()

{

int k = 8;

int x = 0 == 1 && k++;

printf(“%d%d\n”, x, k);

}

a)

a) 0 9

b)

b) 0 8

c)

c) 1 9

d)

d) 1 8

20.

#include<stdio.h>

int main()

{

char j=1;

while(j < 5)

{

printf("%d, ", j);

j = j+1;

}

printf("\n");

return 0;

}

a)

1 2 3 ... 127

b)

1 2 3 ... 255

c)

1 2 3 ... 127 128 0 1 2 3 ... infinite times

d)

1, 2, 3, 4

21.

What is the output of C Program.?

int main()

{

int k;

for(printf("FLOWER "); printf("YELLOW "); printf("FRUITS "))

{

break;

} return 0;

}

a)

Compiler error

b)

FLOWER FRUITS

c)

FLOWER YELLOW

d)

FLOWER YELLOW FRUITS

22.

What would be the size of the following union declaration? (Assuming size of double = 8, size of int = 4, size of char = 1)

a)

4

b)

8

c)

40

d)

80

23.

What will be the output of the following C code

a)

6 -6 0 0

b)

6 -5 0 1

c)

-6 -6 0 1

d)

6 -6 0 1

24.

(A272)16 = (?)8

a)

122272

b)

221172

c)

121162

d)

None of the above

25.

float arr[100];

printf("%d", sizeof(arr));


printf statement will print the sizeof value for the array, what will be the output?

a)

100

b)

400

c)

800

d)

Compiler Dependent