Practice 40 C Basics multiple-choice questions designed for CDAC CCAT exam preparation. Click "Show Answer" to reveal the correct option with detailed explanation.
Show Answer & Explanation
Correct Answer: A — Dennis Ritchie
C was developed by Dennis Ritchie at Bell Labs in the early 1970s.
Show Answer & Explanation
Correct Answer: A — UNIX
C was developed to write the UNIX operating system.
Show Answer & Explanation
Correct Answer: A — C89
C89 (ANSI C) is one of the official C language standards.
Show Answer & Explanation
Correct Answer: C — boolean
C does not have a built-in boolean keyword.
Show Answer & Explanation
Correct Answer: B — char
char data type is used to store a single character.
Show Answer & Explanation
Correct Answer: B — 4 bytes
On most modern systems, int occupies 4 bytes.
Show Answer & Explanation
Correct Answer: B — long
The long modifier increases the size/range of integer.
Show Answer & Explanation
Correct Answer: C — const
const prevents modification of a variable.
Show Answer & Explanation
Correct Answer: B — int
By default, main() returns an integer value.
Show Answer & Explanation
Correct Answer: C — stdio.h
printf() is declared in stdio.h.
Show Answer & Explanation
Correct Answer: B — ;
Every C statement ends with a semicolon.
Show Answer & Explanation
Correct Answer: B — _num
Variable names can start with underscore.
Show Answer & Explanation
Correct Answer: B — const
const keyword declares read-only variables.
Show Answer & Explanation
Correct Answer: B — scanf()
scanf() is used for formatted input.
Show Answer & Explanation
Correct Answer: C — long double
long double provides highest floating-point precision.
What is the output of the following code?
int x = 5;
printf("%d", x);Show Answer & Explanation
Correct Answer: A — 5
x is initialized to 5 and printed.
Show Answer & Explanation
Correct Answer: C — array
Array is a derived data type.
Show Answer & Explanation
Correct Answer: B — volatile
volatile prevents compiler optimizations.
Show Answer & Explanation
Correct Answer: B — &
& operator returns the address of a variable.
Show Answer & Explanation
Correct Answer: B — Platform dependent
C programs depend on underlying hardware and OS.
Show Answer & Explanation
Correct Answer: B — printf("%d", x);
printf with %d format specifier is used to print integers.
Show Answer & Explanation
Correct Answer: A — 1 byte
char always occupies 1 byte in C.
Show Answer & Explanation
Correct Answer: A — unsigned int x;
Correct syntax is modifier followed by data type.
Show Answer & Explanation
Correct Answer: C — register
register suggests the compiler to store variable in CPU register.
What will be the output?
int a = 10;
printf("%d", sizeof(a));Show Answer & Explanation
Correct Answer: B — 4
sizeof(int) is typically 4 bytes on modern systems.
Show Answer & Explanation
Correct Answer: D — All of the above
Integer, floating, and character constants are valid.
Show Answer & Explanation
Correct Answer: B — \n
\n moves the cursor to next line.
What is the output?
printf("Hello
World");Show Answer & Explanation
Correct Answer: D — Hello then World in next line
\n causes a line break.
Show Answer & Explanation
Correct Answer: C — No header required
sizeof is a compile-time operator.
Show Answer & Explanation
Correct Answer: D — Special symbols
Special symbols like @, # are not allowed.
Show Answer & Explanation
Correct Answer: A — extern
extern is used to declare global variables across files.
What will be the output?
int x;
printf("%d", x);Show Answer & Explanation
Correct Answer: B — Garbage value
Uninitialized local variables contain garbage values.
Show Answer & Explanation
Correct Answer: B — float
float stores decimal (fractional) values.
Show Answer & Explanation
Correct Answer: B — Prevents optimization
volatile tells compiler value may change unexpectedly.
Show Answer & Explanation
Correct Answer: A — sizeof
sizeof operator returns memory size in bytes.
Show Answer & Explanation
Correct Answer: B — %lf
double uses %lf in scanf and printf.
Show Answer & Explanation
Correct Answer: D — Both A and B
C supports both single-line and multi-line comments.
What is the output?
printf("%c", 65);Show Answer & Explanation
Correct Answer: B — A
ASCII value 65 represents character 'A'.
Show Answer & Explanation
Correct Answer: C — void
void indicates no return value.
Show Answer & Explanation
Correct Answer: C — return 0;
return 0 indicates successful execution.