wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Introduction & Basic Program Structure

Total questions: 10

Worksheet time: 3mins

Name
Class
Date
1.

Which of the following is a valid C main() declaration?

a)

main() { ... }

b)

void main() return 0;

c)

int main() { return 0; }

d)

int main;

2.

Every C program must have a main() function.

a)

True

b)

False

3.

In C, each statement must end with:

a)

Colon, :

b)

Semicolon, ;

c)

Period, .

d)

Parentheses, ()

4.

What will the output be?

a)

gcc.exe: fatal error: no input files

b)

Hello World

c)

HelloWorld

d)

gcc.exe: fatal error: no input files

e)

"C:\path\to\your\compiler.exe" failed to launch (exit code: 0)

5.

Which format specifier(s) are used for an integer in printf? Select more than one answer (Select all that apply)

a)

%f

b)

%d

c)

%c

d)

%i

e)

%s

6.

What will the following code output?

a)

A

b)

Hello World

c)

format '%i' expects argument of type 'int', but argument 2 has type 'char'

d)

65

7.

Which of the following is the correct way to read an integer input into variable num?

a)

scanf("%d", num);

b)

scanf("%i", &num);

c)

scanf("%s", &num);

d)

scanf("%d", &num[]);

8.

What will the following code print?

a)

2

b)

0

c)

2.5

d)

10

9.

Which is a valid constant definition in C?

a)

PI const float = 3.142;

b)

#define PI = 3.142;

c)

const PI = 3.142;

d)

#define PI 3.142

10.

What is the output of the following code?

a)

20

b)

11 11

c)

10 10

d)

10 11