What is the first step in writing a C program?
A
Compile the code B
Write the source code C
Run the program D
Install Python
Analysis & Theory
The first step is to write the source code using a text editor or IDE.
Which tool is used to convert C code into machine code?
A
Interpreter B
Assembler C
Compiler D
Debugger
Analysis & Theory
A compiler translates C source code into machine (executable) code.
Which of the following file extensions is used for C source code?
A
.cpp B
.py C
.c D
.java
Analysis & Theory
C programs are saved with a `.c` file extension.
Which header file must be included to use `printf()`?
A
math.h B
stdlib.h C
conio.h D
stdio.h
Analysis & Theory
`stdio.h` contains declarations for `printf()` and `scanf()`.
Which of the following is the correct way to write the main function?
A
start main() B
function main() C
int main() D
main void()
Analysis & Theory
`int main()` is the standard way to define the main function in C.
What is the purpose of `return 0;` in the main function?
A
To stop the program B
To indicate successful execution C
To print output D
To declare a variable
Analysis & Theory
`return 0;` tells the operating system that the program ran successfully.
How do you compile a C program using GCC in the terminal?
A
gcc program.c B
run program.c C
execute program.c D
compile program.c
Analysis & Theory
`gcc program.c` compiles the C source file using the GCC compiler.
Which function is used to receive input from the user?
A
printf() B
cin>> C
scanf() D
input()
Analysis & Theory
`scanf()` is used to take input from the user in C.
Which symbol is used to include a header file?
A
# B
% C
& D
$
Analysis & Theory
The `#` symbol is used in C for preprocessor directives like `#include`.
Which of the following is a valid C statement?
A
print('Hello'); B
output('Hello'); C
printf("Hello"); D
println("Hello")
Analysis & Theory
`printf("Hello");` is the correct syntax for printing output in C.