0% found this document useful (0 votes)
8 views2 pages

Cosc102 Exam 17 - 18

Uploaded by

tammytotoife
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

Cosc102 Exam 17 - 18

Uploaded by

tammytotoife
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

BABCOCK UNIVERSITY

IUSAN-REMO, OGUN STATE, NIGERIA.


SCHOOL OF COMPUTING AND ENGINEERING SCIENCES
COMPUTER SOENCE DEPARTMENT

COURSE: Introductiol) to Programming in C++ (COSC102) SESSION: 20 I 7/2018


SEMESTER: 2ND TIME: 90 MINUTES
LECTURERS: Adekola D., Omotunde A. PhD , Akande 0 .
DATE: A ril 11 , 2018 Time: 2-4 m Venue: WRA, 8007 GROUP: CIS/CS/CT

SECTION A (Attemot all)


I) One notable add ition that advanced C++ from C 11 . What does it mean for C++ to be strongly
language is: typed?
A. Data Abstraction 8. Object Orientation
C. Standard libraries D. structured conceot
2. Consider the following code sequence, state the value 12. Write a conditional statement to test if a
of y in the output: particular integer input value falls within the range
int X = 5, y = 6; 40 - 49.
cout <<y++;

A.1 8.6 ,C. II D. 5


3. i=3; 13. What is the scope of a local variable
if(i-2); ... ........... ..... ...
cout<<Goodluc)G what is the output?
4. Write out the C++ statement to reference score of the 14. What is a Token?
third students in an array.
5. Evaluate the following: y = 2 • 5 • 5 + 3 • 5 + 7; 15. C++ was written by .. ............ ....... .
-
A. 72 8. 272 C. 1040 D. 50
6. The syntax: #tkjine <identifier> <valiu> is the for 16. Default header file for C++ is
what type of constant
A. Declared Constant B. Defined Constant A. stdio B. conio C. iostrearn D. stdlib
C. Defined Constant D. None of these
;U_7. Given the algebraic equationy = ax 3 + 7,
7. A modifier is used to alter the meaning of the base data
type so that it more precisely fits the needs of various!which of the following, if any, is correct C++
situations. TI1e syntax is as statement for this equation?
follows:
A. y=a•x•x• 8. y=a*(x*x*x)
x+7; +7;
C. y=a•x•(x• D. y =(a• x) • x • x +
X + 7 ); 7;
8. A is a named memory location 18. An identifier refers to a variable name
which can be give;n to a value, or an expression. A. True 8. False

9. Find the odd one: 19. is a formal


i description of data a value is.
A. Static 8. Int
C. Char i' D. float
10. Human readable form of code is known 20. _ _ _ is used to open a function body and
as - - - is used to close it.
A. SourceCod1 8 . Machine Code
C. Native Code, D. None of these
SECTION B (AtteD1pt any 2 questions) (10 marks each)
I. a. Using switch-case write a C++ program to develop an application that simulates an ATM
machine interface. The simulation should include the followings ATM operations:
i. Withdrawal ii. Enquiry iii Transfer iv. Airtime Recharge
b. Write a program having two functions such that one of the functions is the main where the
other is the addition. Your main is to receive input values of three integers from the user and
send to function addition. Function addition is to find the summation of the integers.
2. A magic word square is a square where a word can be fonned from reading each row and each
column. For example, the following is a 4 by 4 magic word square:

'P' ' R' 'E' ' Y'


' L' 'A ' ·v· ' A'
'O' 'V' ' E' 'R'
'T' 'E' 'N' ' D'

(a) Declare and initialize a two dimensional chmcter array named magicS to hold the -:ach
character illustrated above.
(b) Write a nested for ... loop to display the elements in the array.
3.
a. You are to develop a generic program that all subject teachers in Senior Secondary School
of Ba!,cock High School can use. The problem is that the teachers do not know the number
of sMlents offering their subjects in advance. Therefore, you are to use while .. loop with
sentinel value to take in the scores of the students.
b. Develop an application that computes both the force applied to an object and area of a
square. Hint: Forre=m X g (where m=mass of an object. g;acceleration due to gravity),
Area of squar~length X length. Hint: g is a constant and use define macro function for
computing square
4. Nigerian Government has contacted you to develop a real time voting system for the coming
2019 presidential election. The presidential candidates are:
(i) Ademola ~yo (ii) Makinde Kayode (iii) Olajire Adegoke (iv) Olufemi Bamiro
With the use of switch case, develop a C++ application that
a. Allow a voter to vote for candidate of choice
b. Produce vote count for each candidate
c. \\'ill continue to run until there is no more voter.
SECTION C: Alternative to Practical (Attempt all)
I. Consider the following code extract and correct the errors

int s11m(int x; int y);


{
int result;
:return = x+y;

,r 2. Write out the output of the following code: ::cout<<"•1n••1n .. •1n••••1n\\");


3. What will be tije output: i. ifsimcard= 0 ii. lfreg= 0 iii. Jfcreditcard= I
if(simcard= IJ{
if(reg= I)

[~
if(creditcard= I)
{
\ cout<<"You can call, send sms and browse, ENJOY "<<end);
} else
cout<<"Buy a credit call card"<<endl;

cout<<"Register your sim card"<<endl;


}else
cout<<"Buy a sim card"<<endl; i
' '

You might also like