CSC201: COMPUTER PROGRAMMING 1-1ST SEMESTER 2019 SESSION-EXAM PAST QUESTION
CSC201: COMPUTER PROGRAMMNG I (2019 SESSION-FUO, 1ST SEMESTER)
INSTRUCTION: ANSWER 4
QUESTIONS ONLY, SECTION A COMPULSORY
SECTION A
1.
QUESTION
ONE
a. With a
skeletal program show how a program could exhibit robustness property.
b. Given that
the area of a circle is A = ∏r2 where pi = 3.1412. Write a C++ program that
implements a return type function and accepts radius as its only argument to
calculate the area of a circle.
2.
QUESTION
TWO
a. The number
4 is well known to be an unlucky number to the Chinese. Write a C++ program
that automatically assigns floor numbering to a 9-storey building built by
Chinese contractor in descending order: Floor 10, Floor 9, Floor 8, Floor 7,
Floor 6, Floor 5, Floor 3, Floor 2, Floor 1 and Ground floor. Note: Floor 4 is
intentionally skipped by the program.
b. Write a
tax-collector routine, as follows: A family pays no tax if its income is less
than $5,000. It pays a 10% tax if its income is $5,000 to $9,999, inclusive. It
pays a 20% tax if the income is $10,000 to $19,999, inclusive. Otherwise, it
pays a 30% tax.
SECTION B
3.
QUESTION
THREE
a. Describe
the four phases a C++ program goes through from when it is written with an
editor to when it is executed.
b. Consider
the sequence: 1 1 2i 3 5 8 13 21 34 … write a program that generates this type
of sequence to the 100th term.
4.
QUESTION
FOUR
a. Explain the
following concepts:
i.
Linkers and Loaders
ii.
Functions and Procedures
iii.
Call by value and Call by reference
iv.
Errors and Exceptions.
b. If a=9 and
b=13, what will be output of the following skeletal program.
int
k, a, b, d;
cout<<”Please enter value for
a”<<endl;
cin>>a;
cout<<”Please enter value for
b”<<endl;
cin>>b;
k
= a++;
d
= b--+1;
Cout<<”k
= “<<k <<”a = “<<a <<”d = “<<d <<”b = “
<<b<endl;
5.
QUESTION
FIVE
a. Explain the
difference between the two ways arguments can be passed to a function. Use a
skeletal C++ program to demonstrate your explanation.
b. Give
reasons for the following statements; illustrate where necessary:
i.
Keywords not used as variable names.
ii.
‘Return’ used at the end of many C++ programs
iii.
Blocks necessary in managing scopes and visibility of
variables
iv.
The operating system may have a part to play in the
naming of variables
v.
Continue and Break statements help in loop management
Comments
Post a Comment