Professional Documents
Culture Documents
Instructions
1. Attempt ALL questions.
2. This assignment should be done in a group of five (5) students
3. Copy of other groups’ work shall be NULLIFIED.
4. Submit your group work on or before Monday 20th July, 2020
Question 1
Using an if else if staircase, write a C++ program that is capable receiving a
character entered through the keyboard using getchar() library function. Your
program should be able to recognize the type of a character entered as a digit, an
upper-case letter or lower-case letter or else print the message “Unrecognized
character”, if none of the mentioned character types is entered.
6 marks
Question 2
Using a for loop, write a C++ program that computes the sums and squares of the
natural numbers between 1 and 10 inclusive. That is, it computes the sum of 1 + 1,
then the square 1 * 1, 2 + 2, then 2 * 2, and so on. Let your output be in the
following format:
1+1= 2 2+2 = 4
1* 1 =1 2*2 = 4
….. …..
10 + 10 = 20 10 * 10 = 100 6 marks
Question 3
Write a C++ program to compute the volume of n number of cylinders. Let the main()
program prompt the user to enter the cylinder dimensions and pass these dimensions to a
function that perform computation of the cylinders volume one after the other, reach time
returning the result to main() that output the results of the cylinders volume in the following
format: The area of cylinder No. 1 is xx cubic meter.
The area of cylinder No. 2 is xx cubic meter.
…
The area of cylinder No. n is xx cubic meter.
Where xx is the volume computed.
(Note: The volume of a cylinder is given by v = r2h.
Qualify any standard constant used in your program) 8 marks