Professional Documents
Culture Documents
COS 101 Revision
COS 101 Revision
6 MARKS
ANY 6 ATTRACTS 1 MARK EACH
LINE NUMBER TYPE OF ERROR
1 Syntax (one missing backslash for comment)
2 Syntax (one missing backslash for comment)
3 Syntax (one missing backslash for comment)
4 Syntax (header file not indicated)
8 Syntax (omission of semi colon)
10 Syntax (missing placeholder)
11 and 15 Semantic and logical (missing braces { } for more
than one executable statement associated with if
statement
SECTION B:
a. i. What is computer science?
SOLUTION 2 marks
Computer Science is about building abstract models of real-world objects or phenomena ½ mark, with the
aim of using the model to solve problems ½ mark by automating the models through the use of algorithm
½ mark, and implementing the algorithm in form of instructions which the computer can understand ½
mark.
Input data:
Output data:
Processing requirements:
THEN
CALCULATE ½ mark
OUTPUT ½ mark
Monthly pay
ELSE
CALCULATE ½ mark
OUTPUT ½ mark
Monthly pay
ii. Draw the flowchart for computing the monthly salary of a worker.
The flowchart should reflect:
a. Salary if a worker does not have overtime
b. Salary if a worker does overtime
SOLUTION 5 MARKS
TOTAL: 14 marks
1. With the use of nested if develop a preliminary visa interview application using C programming language.
The application should be able to test if an applicant is qualified for a visa based on the following dependent
conditions.
i. If you are a born Nigerian, if not, it will instruct you to regularize your citizenship
ii. Have a genuine purpose for traveling, if not, it will output visa denied based on purpose
iii. If you are married, if yes--grant visa, if no—it will output visa denied 10 marks
SOLUTION: 10 MARKS
2. Using C language develop an application that will aid a prospective University student to determine his/her
preliminary admission status. The program should determine admission status based on student age and
UTME score. According to JAMB, a student should not be less than 16 and UTME score must not be less
than 200 in order to gain admission into any University in Nigeria.
i. Using a single option if statement determine if a student is qualified to gain admission into the university.
ii. Develop another application that uses double or alternate option if statement that will instruct the user whether
he/she is qualified or not. 10 marks
SOLUTION 3ii:
Revision on Compound If and Switch Case
(a) Briefly describe the concept of control structure. (Read about this !!!)
(b) Suppose you're given a scenario where a student's eligibility for a discount at a movie
theater is determined based on their age and whether they are a student or not. Write a C
program that takes the age and student status (1 for student, 0 for non-student) as input and
outputs whether the student is eligible for a discount or not using compound using if
statement.
Conditions:
i. Students aged 18 or below are eligible for a discount.
ii. Non-students aged 60 or above are eligible for a discount.
Solution:
// A C program to check student eligibility for discount using compound if statement
#include <stdio.h>
int main()
{
// Variable declaration
int age, isStudent;
// Input age and student status
printf("Enter your age: ");
scanf("%d", &age);
printf("Are you a student? (1 for yes, 0 for no): ");
scanf("%d", &isStudent);
// Check eligibility for discount
if ((age <= 18 && isStudent == 1) || (age >= 60 && isStudent == 0))
{
printf("You are eligible for a discount.\n");
}
else
{
printf("Sorry, you are not eligible for a discount.\n");
}
return 0;
}
Question
(a) With the aid of a diagram, describe the switch case structure. (Read about this !!!)
(b) As a microbiology student, you are studying different types of microorganisms and their
characteristics. Write a C program to help classify microorganisms based on their type. The
program should take a character representing the type of microorganism as input and output
its classification.
Microorganism types and their classifications:
B: Bacteria
V: Virus
F: Fungus
P: Protozoa
Use a switch case statement to classify the microorganism based on its type. If the input
character does not match any of the specified types, output "Unknown microorganism
type." 10 marks
Solution:
// A C program to classify micro-organism using switch case statement
#include <stdio.h>
int main() {
char microorganismType;
return 0;
}