C Programming MCQs with Answers for Placement Tests
Q. 1 Which of the following is not a valid C variable name?
Check Solution
Ans: A
In C, int is a reserved keyword and cannot be used as a variable name. Variable names can contain letters, numbers, and the underscore character, but they must start with a letter or an underscore.
Q. 2 What is the correct syntax for a for loop?
Check Solution
Ans: A
The standard syntax for a for loop in C is for (initialization; condition; increment). The three parts are separated by semicolons.
Q. 3 Which of the following functions is used to read a single character from the console?
Check Solution
Ans: C
getchar() reads a single character from the standard input (the console). scanf() reads formatted input, and gets() and printf() are for string input and formatted output, respectively.
Q. 4 What is the output of printf(“%d”, 5/2); in C?
Check Solution
Ans: B
In C, when two integers are divided, the result is also an integer. The fractional part is truncated, so 5/2 results in 2.
Q. 5 Which header file should be included for using the malloc() and calloc() functions?
Check Solution
Ans: B
The malloc() and calloc() functions, used for dynamic memory allocation, are defined in the stdlib.h (Standard Library) header file.
Q. 6 What does the & operator represent in C?
Check Solution
Ans: A
The & operator, known as the address-of operator, is used to get the memory address of a variable.
Q. 7 Which of the following is an example of a preprocessor directive?
Check Solution
Ans: A
Preprocessor directives, which begin with the # symbol, are instructions for the C preprocessor. #include is used to include header files.
Q. 8 What is a pointer in C?
Check Solution
Ans: B
A pointer is a variable that stores the memory address of another variable. This allows for efficient manipulation of data and direct memory access.
Q. 9 Which loop is guaranteed to execute at least once?
Check Solution
Ans: C
The do-while loop checks its condition after executing the body of the loop, so it is guaranteed to run at least once.
Q. 10 Which of the following is used to terminate a switch statement?
Check Solution
Ans: B
The break keyword is used to exit the switch statement once a case match is found, preventing the program from executing the next case’s code.
Next Topic: C++ MCQs with Answers for Placement Tests
Practice Aptitude Questions for Placements
Crack Placement Tests: Faster & Smarter
Adaptive Practice | Real Time Insights | Resume your Progress
