Font size
WorksheetsIntroduction & Basic Program Structure
Total questions: 10
Worksheet time: 3mins
Which of the following is a valid C main() declaration?
main() { ... }
void main() return 0;
int main() { return 0; }
int main;
Every C program must have a main() function.
True
False
In C, each statement must end with:
Colon, :
Semicolon, ;
Period, .
Parentheses, ()
What will the output be?
gcc.exe: fatal error: no input files
Hello World
HelloWorld
gcc.exe: fatal error: no input files
"C:\path\to\your\compiler.exe" failed to launch (exit code: 0)
Which format specifier(s) are used for an integer in printf? Select more than one answer (Select all that apply)
%f
%d
%c
%i
%s
What will the following code output?
A
Hello World
format '%i' expects argument of type 'int', but argument 2 has type 'char'
65
Which of the following is the correct way to read an integer input into variable num?
scanf("%d", num);
scanf("%i", &num);
scanf("%s", &num);
scanf("%d", &num[]);
What will the following code print?
2
0
2.5
10
Which is a valid constant definition in C?
PI const float = 3.142;
#define PI = 3.142;
const PI = 3.142;
#define PI 3.142
What is the output of the following code?
20
11 11
10 10
10 11
