Multiple Choice Questions (MCQs)
In this guide, you'll find a collection of essential C language MCQs, These cover important questions asked in previous held exams and important questions from exam point of view.
Question 1:
Compiler generates..........files.
- A) Executable code
- B) Object code
- C) Assembly code
- D) None of these
Answer:
- B) Object code
Question 2:
What function can be used to free the memory allocated by calloc?
- A) Dealloc
- B) Streat
- C) Free
- D) Memory
Answer:
- C) Free
Question 3:
What will be the output of the following C code?
#include <stdio.h>
void main() {
char a = 'a';
int x = (a % 10)++;
printf("%d\n", x);
}- A) 6
- B) Junk value
- C) Compile time error
- D) 7
Answer:
- C) Compile time error
Question 4:
What is the maximum number of dimensions an array in C may have?
- A) Two
- B) Eight
- C) Twenty
- D) Theoretically no limit
Answer:
- D) Theoretically no limit
Question 5:
Which of the following is a correct syntax to declare a pointer in C?
- A)
int *ptr; - B)
int ptr*; - C)
int ptr; - D)
pointer int ptr;
Answer:
- A)
int *ptr;
Question 6:
What is the size of int in C?
- A) 2 bytes
- B) 4 bytes
- C) 8 bytes
- D) 16 bytes
Answer:
- B) 4 bytes
Question 7:
Which of the following is used to terminate a string in C?
- A)
\0 - B)
\n - C)
\t - D)
\r
Answer:
- A)
\0
Question 8:
What does the sizeof() operator return in C?
- A) The number of elements in an array
- B) The total memory used by a variable in bytes
- C) The address of a variable
- D) The data type of a variable
Answer:
- B) The total memory used by a variable in bytes
Question 9:
Which of the following is NOT a valid pointer operation in C?
- A)
ptr++ - B)
++ptr - C)
ptr+2 - D)
ptr--2
Answer:
- D)
ptr--2
Question 10:
Which header file is required for the printf() function in C?
- A)
#include <stdlib.h> - B)
#include <stdio.h> - C)
#include <conio.h> - D)
#include <math.h>
Answer:
- B)
#include <stdio.h>
Question 11:
Which of the following is used for a comment in C?
- A)
// comment - B)
/* comment */ - C)
<!-- comment --> - D) Both A and B
Answer:
- D) Both A and B
Question 12:
What is the output of the following code?
#include <stdio.h>
int main() {
int a = 5, b = 2;
printf("%d", a / b);
return 0;
}- A) 2.5
- B) 2
- C) 0
- D) 5
Answer:
- B) 2
Question 13:
Which of the following is true about a for loop in C?
- A) Initialization is executed only once
- B) The condition is checked before each iteration
- C) Increment/decrement is executed after each iteration
- D) All of the above
Answer:
- D) All of the above
Question 14:
What is the purpose of the break statement in C?
- A) To terminate the loop entirely
- B) To skip the current iteration of the loop
- C) To jump to the next case in a switch statement
- D) None of the above
Answer:
- A) To terminate the loop entirely
Question 15:
Which operator is used to access members of a structure through a pointer in C?
- A)
. - B)
-> - C)
& - D)
*
Answer:
- B)
->
Question 16:
Which of the following is not a reserved keyword in C?
- A)
auto - B)
case - C)
main - D)
default
Answer:
- C)
main
Question 17:
A C variable cannot start with:
- A) A number
- B) An alphabet
- C) Both of these
- D) A special symbol other than underscore
Answer:
- A) A number
Question 18:
What does the following declaration mean?
int (*ptr)[10];- A)
ptris an array of pointers to 10 integers - B)
ptris a pointer to an array of 10 integers - C)
ptris an array of 10 integers - D)
ptris a pointer to an integer
Answer:
- B)
ptris a pointer to an array of 10 integers
Question 19:
The keyword used to transfer control from a function back to the calling function is:
- A)
switch - B)
goto - C)
go back - D)
return
Answer:
- D)
return
Question 20:
Specify the two library functions to dynamically allocate memory:
- A)
malloc()andmemalloc() - B)
alloc()andmemalloc() - C)
malloc()andcalloc() - D)
memalloc()andforalloc()
Answer:
- C)
malloc()andcalloc()