Basic C Programming MCQs
Which of the following is the correct way to declare a variable in C?
- a)
int number;
- b)
int number()
- c)
integer number;
- d)
num int;
Answer: a) int number;
Which function is used to print output to the screen in C?
- a)
print()
- b)
printf()
- c)
echo()
- d)
write()
Answer: b) printf()
Which of the following is not a valid C variable name?
- a)
int _num;
- b)
int num123;
- c)
int 123num;
- d)
int num_123;
Answer: c) int 123num;
What is the correct syntax to include the standard input-output library in a C program?
- a)
#include <stdio>
- b)
#include <stdio.h>
- c)
#include <stdlib.h>
- d)
#include stdio.h
Answer: b) #include <stdio.h>
What is the size of the int
data type in C (on a typical 32-bit system)?
- a) 1 byte
- b) 2 bytes
- c) 4 bytes
- d) 8 bytes
Answer: c) 4 bytes
Which keyword is used to define a constant variable in C?
- a)
constant
- b)
final
- c)
const
- d)
define
Answer: c) const
Which of the following is not a loop structure in C?
- a)
for
- b)
while
- c)
do-while
- d)
repeat-until
Answer: d) repeat-until
Which operator is used to access the value at the address stored in a pointer variable?
- a)
*
- b)
&
- c)
->
- d)
.
Answer: a) *