Which header file is required to use the printf() function?
A#include
B#include
C#include
D#include
Correct Answer:
B. #include
Explanation:
The stdio.h (Standard Input Output) header file contains declarations for printf(), scanf(), and other input/output functions. It is essential for console I/O operations.
Parentheses have the highest precedence in C. Expressions within parentheses are evaluated first, followed by arithmetic operators, then logical operators, and finally assignment operators.
What is the purpose of the break statement in a loop?
APause the loop temporarily
BExit the loop immediately
CRestart the loop
DSkip the current iteration
Correct Answer:
B. Exit the loop immediately
Explanation:
The break statement exits or terminates the current loop immediately. Option D describes continue (which skips to next iteration), while break actually exits the loop.
In C programming, which of the following is NOT a valid data type?
Aint
Bfloat
Cstring
Ddouble
Correct Answer:
C. string
Explanation:
In C, 'string' is not a primitive data type. C uses 'char' arrays to represent strings. The valid primitive data types are int, float, double, char, void, and their variants.
Which of the following is used to declare a constant in C?
Aconstant int x = 5;
Bconst int x = 5;
Cfinal int x = 5;
Dimmutable int x = 5;
Correct Answer:
B. const int x = 5;
Explanation:
In C, the 'const' keyword is used to declare constants. Once a const variable is initialized, its value cannot be changed. Options A, C, and D are not valid C syntax.
What is the purpose of the return statement in a C function?
ATo exit the program
BTo return a value to the caller and exit the function
CTo declare variables
DTo create a loop
Correct Answer:
B. To return a value to the caller and exit the function
Explanation:
The return statement is used to exit a function and return a value (if any) to the calling function. If the function has return type void, no value is returned.