Learn C MCQs
Prepare C MCQs (Multiple choice Questions) for exam and job interviews.
What is the purpose of the `exit()` function in C?
1) To terminate the program
2) To return a value
3) To pause execution
4) To restart the program
Answer : To terminate the program
Which of the following correctly defines a structure in C?
1) struct name {int a;};
2) struct name {int a; int b;};
3) struct {int a;};
4) Both 1 and 2
Answer : Both 1 and 2
What is the output of printf("%d", 10 % 6);?
1) 4
2) 0
3) 1
4) 2
Answer : 4
Which of the following is not a valid string function in C?
1) strcat()
2) strcpy()
3) strlen()
4) strend()
Answer : strend()
What will be the output of printf("%d", 4 * 5 + 3);?
1) 23
2) 27
3) 20
4) 19
Answer : 23
Which of the following correctly declares an array of 10 integers?
1) int arr[10];
2) int arr(10);
3) int arr{10};
4) int arr[];
Answer : int arr[10];
What is the output of printf("%d", (8 / 4) + (3 * 2));?
1) 9
2) 7
3) 10
4) 6
Answer : 9
Which of the following is true about arrays in C?
1) They are fixed size.
2) They can store different data types.
3) They are dynamic in size.
4) None of the above
Answer : They are fixed size.
What will be the output of printf("%d", 5 + 2 * (3 - 1));?
1) 11
2) 13
3) 10
4) 9
Answer : 11
Which of the following is used to free dynamically allocated memory?
1) delete
2) free()
3) dispose()
4) remove()
Answer : free()