CIT 202 Test1 - 2020-2021

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Bowen University, Iwo;

Computer Science Programme


CIT 202 Test1 2020-2021 May 2021
Instruction: Answer Questions 1, 2 and all the questions in EITHER Section A OR Section B .
Time 1 hour : 30 minutes

SECTION A

1. Write a C++ program to input the length and breadth of a rectangle, compute the area,
perimeter and length of the diagonal of the rectangle. The program is also to output the
input values on one line and the computed values on a separate line.
2. With respect to the C++ declaration, : int n =7; int sum=5; write out the values of n and
sum after the following expressions is executed: (i) n++; (ii) sum *=6’ (iii) sum % n

SECTION B

3. How many times will the following program loops be executed?:


i) for (int i=0; i<=10; i++) cout << i;
ii) for (int i=10; i>; i-- cout << i;
iii) n=5; while (n>0) n--

4. Specify the header files in which the following functions are found: (i) stren (ii) atof (iii)
exit() (iv) floor (v) exp
5.
a
(i) Write one C++ statement to output n , assume a and n have been declared and
given initial values
(ii) Write C++ declarations for identifiers a, b, c, d and e which take string, Boolean,
floating-point, char and integer values respectfully
(iii) Write one C++ statement to read values into 2 variables x and y; assume x and y
have been declared as of type char and integer respectively
6. A function with two integer parameters a and b is required to compute the sum s and
product p of a and b via parameters. write the prototype of the function.

7. List 3 basic control structures for structured coding (b) what C++ statements are used for
multiple selection and post-test iteration.

SECTION C

8. Oi
i) Write a for-statement equivalent of the following C++ program segment:

int prod =1;


int n=5;
do
{
prod *=n;
n—
}
While (n > 0)
ii) What is the program segment doing?
9. Concisely state the uses of the following built-in C++ functions: (i) strlen (ii) atof (iii)
exit (iv) floor (v) exp
10.
5
i) Write C++ notation for the expression (x+n)
ii) List 2 functions contained in the iostream header file
iii) Write a C++ program segment to output “a equals b” if the values of a and b are
the same and output “a is not equal to b”, if otherwise. Assume a and b have been
declared and given values

11. List the 3 techniques involved in structured programming methodology and describe just
one of the techniques

Assignment to be submitted on Thursday 20 May 2021

12. A program is required to input exam scores of 100 students, compute and then output the
following
i) average score
ii) Highest score
iii) Median score
iv) the entire score in ascending order
Design the structure of the program, using Top-down design strategy

13. Write a program to output the sum of the first 10 integers using three (3) iteration control
structures
14. Write a program to input exam scores based on 100% then output the score and its grade,
using Bowen University grading system for your set.

You might also like