wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Structured Programming

Total questions: 11

Worksheet time: 4mins

Name
Class
Date
1.

Which statement about global variables is TRUE?

a)

They can be accessed in any function

b)

They disappear after one function finishes

c)

They can only be accessed in the main() function

d)

They works just like local variable

2.

What’s the main danger of using global variables?

a)

They eat up all your RAM

b)

Any function can change them

c)
  • They leak your code to the internet automatically

d)
  • They cannot store integers

3.

In C, what’s the difference between <stdio.h> and "myLib.h"?

a)

<stdio.h> is used for code indentation

b)

They are exactly the same

c)

< > is for built-in libraries, " " is for custom libraries

d)

myLib.h makes your code compile 2x faster

4.

What will this code output?

a)

Nothing

b)

C

c)

Compilation error

d)

20

5.

Which of these functions can generate a random number?

a)

rand()

b)

printf("%d", luckyNum);

c)

scanf("%d", &rand);

d)

randomNumberPlease()

6.

In a flowchart, which shape represents a decision?

a)

Diamond

b)

Rectangle

c)

Oval

d)

Triangle

7.

What will this program print?

a)

10

b)

5

c)

15

d)

Both 5 and 10

e)

error: expected ')' before '}' token

8.

What would the output be?

a)

HiHello

b)

Undefined behavior

c)

HelloHi

d)

Hello

e)

Hi Hello

9.

Which library is needed to use bool in C?

a)

<stdlib.h>

b)

<stdbool>

c)

<boolean.h>

d)

<stdbool.h>

10.

Which defines a proper global constant?

a)

const float PI = 3.14;

b)

float const = 3.14;

c)

constant float PI = 3.14;

d)

#define const PI = 3.14;

11.

In structured programming, what is “selection”?

a)

Running every line in sequence

b)

Repeating blocks of code

c)

Choosing between alternatives using conditions

d)

Selecting your favorite IDE in lab class