Learn C MCQs
Prepare C MCQs (Multiple choice Questions) for exam and job interviews.
Which of the following is used to copy one string to another in C?
1) strcpy()
2) strcat()
3) strlen()
4) strncpy()
Answer : strcpy()
What is the output of printf("%d", (5 && 0) || (0 && 5));?
1) 1
2) 0
3) 5
4) 10
Answer : Option 2
Which of the following functions is used to dynamically allocate memory in C?
1) malloc()
2) calloc()
3) realloc()
4) All of the above
Answer : All of the above
What will be the output of printf("%d", 4 * (3 + 2));?
1) 15
2) 20
3) 25
4) 12
Answer : 20
Which of the following data types can store decimal values in C?
1) int
2) float
3) char
4) void
Answer : float
What is the purpose of the `continue` statement in a loop?
1) To skip the current iteration
2) To terminate the loop
3) To break out of a function
4) None of the above
Answer : To skip the current iteration
What will be the output of printf("%d", (10 > 5) ? 1 : 0);?
1) 1
2) 0
3) 10
4) 5
Answer : 1
Which of the following can be used to terminate a `for` loop prematurely?
1) break
2) continue
3) return
4) exit
Answer : break
What is the output of printf("%d", 1 + 2 * 3);?
1) 7
2) 6
3) 5
4) 8
Answer : 7
What is the correct way to declare an array of strings in C?
1) char arr[][10];
2) char **arr;
3) char arr[10][10];
4) Both 1 and 3
Answer : Both 1 and 3