wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Basic Algorithm in C (Data type, Expression, Branching, Looping)

Total questions: 40

Worksheet time: 36mins

Name
Class
Date
1.

What is the role of the Central Processing Unit (CPU) in a computer?

a)

It stores data and instructions.

b)

It executes instructions and performs calculations.

c)

It allows communication with external devices.

d)

It performs arithmetic and logical operations.

2.

What does the memory unit do in a computer?

a)

It stores data and instructions currently being used.

b)

It executes instructions.

c)

It directs the flow of data.

d)

It allows communication with external devices.

3.

Logical units in a computer, some of which include...

(Select all correct answers)

a)

Arithmetic and Logic Unit (ALU), Control Unit (CU)

b)

Input/Output Unit

c)

Power Supply Unit (PSU)

d)

Storage Unit

e)

Graphics Processing Unit (GPU)

4.

What is an algorithm?

a)

A type of computer hardware component.

b)
An algorithm is a step-by-step procedure for solving a problem.
c)
A random guess without any steps.
d)
A recipe for cooking a meal.
5.

Which of the following is one of the requirements of a good algorithm?

a)

A good algorithm must have well-defined inputs and outputs.

b)

A good algorithm should be complex to solve problems efficiently.

c)
It should only focus on speed without considering accuracy.
d)

A good algorithm must be written in a programming language.

6.

What is algorithm notation?

a)
Algorithm notation is a method for writing code.
b)

A set of rules for executing an algorithm on a computer.

c)

Algorithm notation is a symbolic or structured way to represent an algorithm.

d)
Algorithm notation is a type of programming language.
7.

What is a flowchart?

a)

A programming language used to implement algorithms.

b)

A diagram that represents the steps of an algorithm using symbols.

c)

A type of software that executes algorithms automatically.

d)

A mathematical symbols used to solve complex problems.

8.

What is a variable?

a)
A variable is a symbolic name for a value that can change.
b)
A variable is a fixed memory location for storing data.
c)
A variable is a type of data structure that holds multiple values.
d)
A variable is a constant value that cannot change.
9.

Which of the following are the rules for naming variables in C programming languages?

(Select all correct answers)

a)

Can start with a number.

b)

Cannot contain spaces.

c)

Cannot use reserved keywords or built-in functions.

d)

Case-Sensitive.

e)

Allowed Characters: Variable names can only consist of letters (A-Z, a-z), numbers (0-9), and underscores (_).

10.

Which of the following are valid variable names in programming? (Select all correct answers)

a)

user_name

b)

2ndValue

c)

_dataCount

d)

int

e)

totalAmount$

11.

Consider the following pseudocode. When this pseudocode is executed, will the output be 6, 4?

a)

YES! ✅

b)

NO! ❌

12.

Consider the following pseudocode, if someone claims that the output of this pseudocode is x = 8 and y = 3, is this statement True or False?

a)

FALSE

b)

TRUE

13.

What is a data type?

a)
A data type is a programming language used for data analysis.
b)
A data type is a method for sorting data in a database.
c)
A data type is a visual representation of data in charts.
d)
A data type is a classification of data that defines the type of value a variable can hold.
14.

BONUS TIME:

Do you want a bonus point?

a)

NO!

b)

YES!

15.

An operator is a value or variable that is manipulated within an expression.

a)

TRUE

b)

FALSE

16.

Which of the following correctly represents the order of operator precedence from highest to lowest?

a)

B - A - D - E - F - C

b)

D - B - E - A - F - C

c)

B - D - A - E - F - C

d)

B - E - D - A - F - C

e)

B - D - E - A - F - C

17.

What is the result of the following Boolean expression?
(3 == 5) || (10 > 2 && 7 < 4)

a)

TRUE

b)

FALSE

18.

10 + 3 * 2 - 8 / 4 % 3

a)
14
b)
16
c)
10
d)
12
19.

Evaluate the following mathematical expression, considering operator precedence:

(20 − 5) + (8 % 3 * ((6 / 2) / 5))
What is the final result?

(a)  

20.

If the following expression is executed in the C programming language, what will be the result?

a)

14

b)

24

c)

27

d)

29

e)

32

21.

BONUS TIME:

Select all 'POINT's and you will get 2 points!

a)

POINT

b)

X

c)

POINT

d)

X

e)

X

22.

What is branching in programming?

a)
Branching is the process of combining multiple code files into one.
b)

Branching refers to the method of repeating a set of instructions multiple times until a condition is met.

c)

Branching is the process of executing a sequence of statements in a linear order without any decision-making.

d)

Branching is a programming concept that allows the execution of different code paths based on conditions.

23.

What will be the output of the following C program?

(a)  

24.

What will be the output of the following C program?

a)

Case A

b)

Case B

c)

Case C

d)

Case D

e)

Case E

25.

What will be the output of the following C program?

a)

Option A

b)

Option B

c)

Option C

d)

Option C and Option D

e)

Option E

26.

Which of the following is NOT a main structure in looping?

a)

Initialization

b)

Condition

c)

Function Call

d)

Update Statement

27.

The following are basic structures in looping, except...

a)

for loops

b)
while loops
c)
do-while loops
d)

Switch-case

28.

What will be the output of the following C program if the user inputs n = 5?

a)

8 7 6 5 4

b)
8 6 4 2 0
c)

8 6 4 2

d)

8 7 6 5 4 3 2

29.

What will be the output of the following C code?

a)
14
b)
20
c)
18
d)
16
30.

If you reach this part, write your favorite pet.

2 lines
31.

If the following C program is executed, what will be the output?

a)

b)

c)

d)

e)

32.

Here are the purposes of 'break' control commands except...

a)

Stops the execution of a loop before the final condition is reached.

b)

Stops execution in a switch-case after a case has been satisfied.

c)

To skip an iteration in a loop and continue with the next one.

d)

To stop execution when a certain condition is met

33.

What is traversal in the context of looping and branching?

a)

Traversal is process of executing a block of code repeatedly based on a condition.

b)

Traversal is a method of skipping iterations in a loop using a control command.

c)

Traversal is process of accessing each element in a data structure systematically.

d)

Traversal is the act of making decisions using conditional statements.

34.

Which of the following is NOT a correct use of traversal in data structures?

a)

Searching: Traversing helps you find a specific element in a data structure.

b)

Sorting: Traversing and comparing data helps you sort the data.

c)

Teleportation: Traversing allows you to instantly access any data without scanning.

d)

Accessibility: Traversing makes data more accessible

e)

Modifying data: Traversing allows you to modify or change data.

35.

BONUS TIME:

Write 'EXTRA' and you will get an extra point!

(a)  

36.

Consider the following C program, what will be the output of this program?

a)
1 2 4 5 7
b)
1 2 3 6 8
c)

1 2 4 5 7 8

d)

1 2 3 4 5 6 7

37.

What will be the output of the following C program?

a)

10 8 7 5 4 2 1 0

b)

10 9 8 7 6 5 4 3 2 1 0

c)

9 8 6 5 3 2 0

d)

9 7 6 4 3 1 0

38.

Tino runs at a speed of 5 meters per second but must rest for 10 seconds after every 50 seconds of running. If he runs for a total duration of 5 minutes (300 seconds), how far will he travel?

(a)  

39.

Consider the following C program, what will be the final value of num after executing this program?

(a)  

40.

Observe the following C program. If the user inputs the value 5, what will be the output?

a)

0 1 3 4 7 11

b)

0 1 1 2 3

c)

0 1 1 2 3 5

d)

0 1 2 3 5 8