[go: up one dir, main page]

0% found this document useful (0 votes)
12 views6 pages

C MCQ Set 1

The document contains a set of 25 multiple-choice questions related to the C programming language. Topics covered include data types, variable naming, operators, control structures, functions, and memory management. Each question provides four answer options, testing knowledge on fundamental concepts in C.

Uploaded by

rrmm
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)
12 views6 pages

C MCQ Set 1

The document contains a set of 25 multiple-choice questions related to the C programming language. Topics covered include data types, variable naming, operators, control structures, functions, and memory management. Each question provides four answer options, testing knowledge on fundamental concepts in C.

Uploaded by

rrmm
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/ 6

Set 1:

1. What is the size of an `int` in C (on most 32-bit systems)?

a) 2 bytes

b) 4 bytes

c) 8 bytes

d) Depends on compiler

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

a) _sum

b) 2data

c) data_2

d) totalAmount

3. What will `printf("%d", 5/2);` output?

a) 2.5

b) 2

c) 3

d) Compilation error

4. Which operator is used for conditional expression in C?

a) :

b) ?

c) if

d) ?:

5. Which keyword is used to prevent modification of a variable?


a) immutable

b) volatile

c) static

d) const

6. Which loop is guaranteed to execute at least once?

a) for

b) while

c) do-while

d) None

7. How many times will the loop run? `for(i=0; i<5; i++)`

a) 4

b) 5

c) 6

d) Infinite

8. What is the correct syntax to declare a pointer to an integer?

a) int ptr

b) int *ptr

c) int &ptr

d) pointer int

9. Which function is used to find the length of a string?

a) strlen()

b) strlength()

c) size()
d) length()

10. Which header file is required for `printf()`?

a) stdlib.h

b) string.h

c) stdio.h

d) conio.h

11. What is the result of `sizeof(char)`?

a) 2

b) 4

c) 1

d) Depends on system

12. Which sorting algorithm is the simplest?

a) Quick sort

b) Bubble sort

c) Merge sort

d) Heap sort

13. What is the purpose of `break` statement?

a) Skip next iteration

b) Stop loop

c) Exit program

d) Continue loop

14. How to take input of a string in C?


a) gets()

b) input()

c) cin

d) scanf("%s", str)

15. What will be the output: `printf("%d", sizeof(3.14));`?

a) 4

b) 8

c) 6

d) Error

16. Which of the following is a unary operator?

a) +

b) ++

c) =

d) &&

17. How to declare a structure in C?

a) struct student {}

b) struct student();

c) structure student{}

d) class student{}

18. What does the `&` operator do?

a) OR

b) NOT

c) Address of
d) AND

19. What is recursion?

a) Function calling another function

b) Looping function

c) Function calling itself

d) None

20. Which function is used to open a file?

a) fopen()

b) openfile()

c) create()

d) fileopen()

21. Which of the following is not a storage class in C?

a) auto

b) register

c) volatile

d) static

22. What is the value of `a` after: `int a = 5; a += 3;`

a) 5

b) 8

c) 3

d) 0

23. What is the output of `5 % 2`?


a) 2

b) 1

c) 0

d) Error

24. Which operator is used for logical AND?

a) &

b) &&

c) |

d) ||

25. How do you declare an array of 10 integers?

a) int a(10);

b) int[10] a;

c) int a[10];

d) array int a[10];

You might also like