Showing 991–1000 of 1,000 questions
Which escape sequence represents a tab character in C?
EXPLANATION
\t is the escape sequence for a tab character. \n is for newline, \s is invalid in C.
What will be the output of: int x = 10; printf("%d %d", x, x++);
A
10 10
B
10 11
C
11 10
D
Undefined behavior
Correct Answer:
D. Undefined behavior
EXPLANATION
Modifying and using a variable in the same expression without an intervening sequence point results in undefined behavior.
What is the purpose of the main() function in C?
A
To declare variables
B
To include header files
C
Entry point of program execution
D
To define functions
Correct Answer:
C. Entry point of program execution
EXPLANATION
The main() function is the entry point where program execution begins. Every C program must have a main() function.
Which of the following is the correct way to define a constant in C?
A
#define PI 3.14
B
const float PI = 3.14;
C
Both A and B are correct
D
Neither A nor B is correct
Correct Answer:
C. Both A and B are correct
EXPLANATION
Both #define and const can be used to define constants in C. #define is a preprocessor directive, while const is a type qualifier.
What is the output of: printf("%d", 5 + 3 * 2)?
EXPLANATION
Following operator precedence, multiplication (*) has higher precedence than addition (+). So 3*2=6, then 5+6=11.
Which of the following is NOT a valid C keyword?
A
extern
B
volatile
C
mutable
D
register
Correct Answer:
C. mutable
EXPLANATION
mutable is a C++ keyword, not a C keyword. extern, volatile, and register are valid C keywords.
What does the following code snippet output?
#include
int main() {
int x = 5;
printf("%d", x++);
return 0;
}
A
5
B
6
C
undefined
D
Compilation error
EXPLANATION
x++ is post-increment. The value 5 is printed first, then x is incremented to 6.
Which header file is required to use the printf() function?
A
#include
B
#include
C
#include
D
#include
Correct Answer:
B. #include
EXPLANATION
stdio.h (Standard Input Output header) is required for printf() and scanf() functions.
What is the size of int data type in a 32-bit system?
A
2 bytes
B
4 bytes
C
8 bytes
D
1 byte
Correct Answer:
B. 4 bytes
EXPLANATION
In a 32-bit system, int is typically 4 bytes (32 bits). The size may vary depending on the compiler.
Which of the following is the correct syntax to declare a variable in C?
A
int x;
B
int x
C
int: x;
D
declare int x;
Correct Answer:
A. int x;
EXPLANATION
In C, variable declaration requires a semicolon at the end. The syntax is 'data_type variable_name;'