Which of the following is the correct way to start a C program?
A
#include <main.h> B
#include <stdio.h> C
#start D
void main()
Analysis & Theory
A C program typically starts by including the necessary header file like `#include <stdio.h>`.
Which of the following correctly declares the `main` function in C?
A
function main() B
main() C
int main() D
void main[]
Analysis & Theory
`int main()` is the standard syntax to define the entry point of a C program.
What symbol must be used at the end of every C statement?
A
: B
. C
; D
!
Analysis & Theory
Each statement in C must end with a semicolon `;`.
Which of the following is a valid variable declaration in C?
A
int 1value; B
int value1; C
int value-1; D
int.value;
Analysis & Theory
Variable names can't start with a digit or contain special characters like `-` or `.`. `value1` is valid.
How do you declare a constant in C?
A
int constant PI = 3.14; B
#define PI 3.14 C
const PI = 3.14; D
constant PI = 3.14;
Analysis & Theory
In C, you can define a constant using `#define PI 3.14`.
Which of these correctly assigns the value 10 to a variable?
A
int x == 10; B
int x = 10; C
int x := 10; D
int = x 10;
Analysis & Theory
`int x = 10;` is the correct way to declare and assign a value in C.
How is a block of code started in C?
A
Using BEGIN B
With a colon `:` C
Using curly braces `{ }` D
With indentation
Analysis & Theory
C uses `{` and `}` to define code blocks.
Which of the following is NOT a valid data type in C?
A
int B
char C
float D
real
Analysis & Theory
`real` is not a valid data type in C. `float` is used for real numbers.
What is the correct way to write a single-line comment in C?
A
# This is a comment B
// This is a comment C
/* This is a comment */ D
-- This is a comment
Analysis & Theory
Single-line comments in C use `//`.
Which of the following functions is used to output data in C?
A
echo() B
cin>> C
print() D
printf()
Analysis & Theory
`printf()` is used in C for formatted output.