0% found this document useful (0 votes)
8 views3 pages

algorithms and programming languages 2022 2023 exams

The document outlines an examination for the course 'Algorithm and Programming Languages' at the University of Bamenda, detailing multiple choice questions and structural problems related to programming concepts. It includes questions on algorithms, data types, loops, and Python programming, as well as tasks requiring flowchart creation and code correction. The exam is structured into two sections: multiple choice questions worth 50 marks and structural questions worth 20 marks.

Uploaded by

bertillamfonfu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views3 pages

algorithms and programming languages 2022 2023 exams

The document outlines an examination for the course 'Algorithm and Programming Languages' at the University of Bamenda, detailing multiple choice questions and structural problems related to programming concepts. It includes questions on algorithms, data types, loops, and Python programming, as well as tasks requiring flowchart creation and code correction. The exam is structured into two sections: multiple choice questions worth 50 marks and structural questions worth 20 marks.

Uploaded by

bertillamfonfu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

REPUBLIC OF CAMEROON THE UNIVERSITY OF BAMENDA

Peace-Work-Fatherland P.O BOX 39 Bambili

School/Faculty: NAHPI Department/Year: ALL/ Year 1 Lecturer(s): Dr. Ndukum. P, Tangu Achilis, Ndjock michel
Course Code: COME2201. Course Title: ALGORITHM AND PROGRAMMING LANGUAGES Course Credits: 4
Date:2022/2023 academic year Hall: Time: 2 hrs
Instructions: Answers ALL questions in an orderly manner

SECTION A: MULTIPLE CHOICE QUESTIONS (50 mrks)


Instructions: choose the letter corresponding to the correct answer
1. What is an algorithm?
A) A computer program B) A set of instructions to solve a problem
C) A programming language D) A data structure
2. What is a loop in programming?
A) A type of data structure B) A way to repeat a set of instructions C) A
function in Python D) A way to define variables
3. What is a compiler in programming?
A) A program that translates source code into machine code B) A program that
translates machine code into source code C) A program that
executes source code D) A program that executes machine code
4. Which data type in Python is used to store a sequence of characters?
A) Integer B) Float C) String D) Boolean
5. What is the output of the following code in Python: print(5 + 3 * 2)
A) 11 B) 13 C) 16 D) 21
6. What is the purpose of a function in programming?
A) To define a variable B) To create a loop C) To perform a specific task D)
To store data
7. What is a boolean operator in programming?
A) An operator that returns a true or false value B) An operator that
performs arithmetic operations C) A loop that executes a set of instructions D)
A way to define a variable
8. What is a variable in programming?
A) A function that returns a value B) A data structure C) A way to store and
manipulate data D) A loop
9. Which data type in Python is used to store a true or false value?
A) Integer B) Float C) String D) Boolean
10. What is the output of the following code in Python: print("Hello" + "World")
A) Hello World B) HelloWorld C) HelloWorld D) Hello + World

Page 1 of 3
11. What is a conditional statement in programming?
A) A loop that executes a set of instructions B) A way to define a variable C) A way
to branch the execution of a program based on a condition D) A data structure
12. Python code is converted to machine code using?
A) Compiler B) Interpreter C) debugger D) Linker
13. What is a parameter in a function?
A) A variable that is defined inside a function B) A variable that is passed into a
function C) A loop that executes a set of instructions D) A conditional
statement
14. Which of the following is not a way of representing algorithms?
A) Pseudo-code B) Structured English C) Flow charts D) Enumeration
15. What is the output of the following code in Python: print(10 // 3)
A) 3.3333 B) 3 C) 3.0 D) 3.33
16. What is the result of the following statement in python: 10>10?
A) 10 B) False C) false D) True
17. Which generation of programming languages uses mnemonics and symbols to
represent instructions?
A) Low-Level Languages B) Second-Generation Languages C) Fourth
Generation Languages D) High Level Languages
18. Which of the following factors will affect your choice for a programming language?
A) Cost B) Tool support C) Time D) Beauty
19. Which of the following is a type of loop in python?
A) do while B) for C) repeat D) foreach
20. What is the output of the following code in Python: print(2 ** 3)
A) 2 B) 3 C) 8 D) 6
21. Which of the following is not a characteristic of a good programming language?
A) Naturalness B) Completion C) Abstraction D) Efficiency
22. Which of the following is not a step in the program development lifecycle?
A) Maintenance B) Security C) Coding D) Problem Definition
23. Which symbol is used to represent a process in a flowchart?
A) Ellipse B) Rhombus C) Rectangle D) Parallelogram
24. Which python function is used to get input from the user?
A) print() B) int() C) input() D) read()
25. What is the output of the following code in Python: print("Hello" * 3)
A) Hello B) HelloHelloHello C) 9 D) Error

Page 2 of 3
SECTION B: Structural 20MRKS
1. Write a flowchart algorithm to that finds the smallest number among three numbers
and hence write a python implementation of the algorithm (10 mrks)
2. The following is a python program that calculates the average of 3 numbers. The
program will not run successfully, correct the code(4mrks)
number1 = input("Enter the first number: ")

number2 = input("Enter the second number: ")

number3 = input("Enter the third number: ")

sum = number1 + number2 + number3


3. The following program
averagechecks
= sum if/ 3a number is negative or positive, the implementation
given bellow has some issue(s) correct it (2 mrks)
# This program checks if a number is positive, negative, or zero
print("The average is:", average)
number = input("Enter a number: ")

if number > 0:

print("The number is positive.")

elif number <= 0:

print("The number is negative.")

else:

print("The number is zero.")average = sum / 3

print("The average is:", average)

4. Given the program bellow(4 mrks)

number = int(input("Enter a number: "))


if number > 100: #first if block
print("The number is greater than 100.")
if number % 2 == 0: #second if block
print("The number is even.")average = sum / 3
print("The average is:", average)

a) Provide a value for number that will cause only the second if block to be executed
b) Provide a value for number that will cause only the first if block to be executed
c) Provide a value for number that will cause only the third if block to be executed
d) Provide a value for number that will cause the first and second if block to
executed

Page 3 of 3

You might also like