0% found this document useful (0 votes)
9 views8 pages

C Programming Test Part1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views8 pages

C Programming Test Part1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

1. Which of the following is the correct format specifier to print a character in C?

A) %f

B) %c

C) %d

D) %s

2. What will be the output of the following code?

int a = 5;

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

A) 5

B) 6

C) Error

D) Undefined

3. What is the size of int datatype in C (in most compilers)?

A) 2 bytes

B) 8 bytes

C) 4 bytes

D) 1 byte

4. Which operator is used to check if two values are equal in C?

A) =

B) ==

C) !=

D) <=

5. Which datatype is most suitable for storing a person's grade like 'A', 'B'?

A) int

B) char

C) float

D) double
6. The ASCII value of character 'A' is:

A) 65

B) 66

C) 64

D) 97

7. What is the output of this flowchart if input number is 6?

Flowchart: Start -> Input N -> N % 2 == 0 -> Yes -> Print "Even"

A) Odd

B) Even

C) Error

D) Nothing

8. Identify the correct format specifier for float datatype.

A) %d

B) %f

C) %lf

D) %x

9. Which keyword is used to make decisions in C programming?

A) repeat

B) switch

C) if

D) select

10. What will be the output of this code?

int a = 10;

if (a > 5)

printf("Greater");

A) Greater

B) Error
C) Less

D) Nothing

11. What is the output of the following code?

int x = 5;

x = x++ + ++x;

printf("%d", x);

A) 11

B) 12

C) 10

D) Compiler Error

12. What is the correct format specifier for double datatype?

A) %d

B) %f

C) %lf

D) %Lf

13. What will be printed by this code?

char ch = 65;

printf("%c", ch);

A) A

B) 65

C) Error

D) a

14. Which of the following evaluates right to left?

A) a = b = c

B) a + b + c

C) a && b && c

D) a || b || c
15. What will this program print?

int a = 10;

if (a > 5 && a < 20)

printf("In Range");

else

printf("Out of Range");

A) Out of Range

B) In Range

C) Error

D) 10

16. What is the output?

int a = 3;

int b = 4;

int c = (a > b) ? a : b;

printf("%d", c);

A) 3

B) 4

C) Error

D) None

17. In which case is a switch statement preferable over if-else?

A) Floating-point conditions

B) Range-based conditions

C) Multiple exact matches

D) None of the above

18. What will be output?

int x = 4;

int y = -x;
printf("%d", y);

A) 4

B) -4

C) Error

D) 0

19. What is the result of 5 > 3 && 3 > 2?

A) 1

B) 0

C) Error

D) Undefined

20. Choose correct option: Which of the following statements is true about float and double?

A) float has more precision

B) double uses less memory

C) double is more precise

D) float stores characters

21. What is the final output?

int a = 2;

int b = 3;

int c = 4;

int result = a + b * c;

printf("%d", result);

A) 20

B) 14

C) 18

D) 24

22. Which flowchart symbol is used for a decision/condition?

A) Rectangle
B) Oval

C) Diamond

D) Parallelogram

23. What is the output?

char ch = 'B';

printf("%d", ch);

A) 66

B) B

C) Error

D) 98

24. Which is the correct order of operator precedence?

A) *, +, =

B) =, +, *

C) +, =, *

D) *, =, +

25. Predict output:

int a = 5;

int b = 10;

if (a > b)

if (a == 5)

printf("A is 5");

else

printf("B is 10");

A) A is 5

B) B is 10

C) Nothing

D) Error
26. What will be the output?

int x = 1;

switch(x) {

case 1: printf("One ");

case 2: printf("Two ");

default: printf("Default");

A) One

B) One Two

C) One Two Default

D) One Default

27. Output of this code?

int a = 10;

int b = 20;

int c = (a > b) ? b : a;

printf("%d", c);

A) 20

B) 10

C) Error

D) 0

28. What is the output?

int i = 0;

if (i = 5)

printf("True");

else

printf("False");

A) True
B) False

C) Error

D) None

29. Which of the following is a unary operator?

A) ++

B) +

C) *

D) >

30. What is the output of this code?

int a = 5;

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

A) 4

B) 8

C) 2

D) 1

You might also like