Cosc112 Second Sem Test Solution
Cosc112 Second Sem Test Solution
Cosc112 Second Sem Test Solution
NO
Name:……………………………………………..
Matric. No:………………………………………
[QUESTION PAPER] TITLE:
INTRODUCTION TO COMPUTER SCIENCE & PROGRAMMING II(COSC112)
1. In C++, a do{…}while(condition) statement ends 6. Translate the following into a C++ expression:
with a semi-colon: True/False? if x < y < z
solution: if((x<y) && (y<z))
2. Re-write the following mathematical expression in 7. Consider the following macro function created by
an acceptable C++ expression: a friend:
#define CUBE(y) (y*y*y)
SECTION B (Attempt ONLY one Question; 5 marks for each) (Write your code in C++ language)
1) Write a C++ program to calculate overtime pay of 5 employees. Overtime is paid at the rate of
N150.00 per hour for every hour worked above 40 hours. Assume that employees do not work
for fractional part of an hour. The program accepts user data: Full Name and number of hours
worked. The program displays each employee’s name, hours worked, total pay and overtime pay.
Soln:
//Section B: Question 1
//Programm tocompute overtime for 5 employee
#include<iostream>
Page 2 of 3 PAPER REF. NO
using namespace std;
int main(){
int overtime_pay, numb_hr,emp_numb;
string name;
double overtime_hr_rate = 150.00;
2) Suppose a bank in Lagos gives loan to business men and women in the following ranges for a
period of 2 years. Write a C++ program to accept the Loan P and compute the Interest using the
formula I given above and the respective rate [Hint: I = PRT/100]
Soln:
//SECTION B:Question 2
//Program to calculate interest given a rate
#include<iostream>
using namespace std;
int main() {
double P, R;
double T = 2.0;
double I;
return 0;