You are on page 1of 6

UNIVERSITY FOR DEVELOPMENT STUDIES

FACULTY OF MATHEMATICAL SCIENCES

DEPARTMENT OF COMPUTER SCIENCE

END-OF-SECOND TIMESTER EXAMINATIONS - 2019/20

DCS 106: PROGRAMMING IN C++ (OBJECT ORIENTED) (3 CREDITS)

Diploma in Computer Science (Level 100) Time allowed: 3 hrs

INSTRUCTION: Answer ALL on the QUESTION PAPER BY CIRCLING THE RIGHT


ANSWER.

Answer all Questions


1. User-defined functions are derived from a. parameters b. literals
a. standard library files. c. arguments d. values
b. namespaces. 5. void is used in function definition if the
c. the main function. function must return a numeric value
d. none of the above. a. True b. False
2. If x and y are integers, then, 6. Given a string, s=”C++ for you”;,
double z=(a*b)/(a+1.0) the statement cout<<s.erase(2,
will yield the same results as . 3); will return …………
double z=(double(a)*b)/(a+1) a. C+or you b. for you
a. True b. False c. C for you d. ++ for you
3. The meaning associated with a particular 7. Executing the statement ++age[2]; on
programming construct is its int age[]={3, 1, 4, 9}; results
………………… to ……
a. syntax. b. semantics. a. {4, 2, 5, 10} b. {3, 2, 4, 9}
c. grammar. d. data type. c. {3, 1, 5, 9} d. {4, 2, 4, 9}
4. Data passed to a function when it is called
are referred to as …………………

1
8. Which of the following is not a
fundamental data type in C++? 15. Which of the following OOP concepts
a. short b. bool enables data hiding?
c. char d. string a. internal functions. b. inheritance.
9. What is the output of the following code c. encapsulation. d.
extract? polymorphism
If(5>10); 16. Given two global arrays int a[5]; and
cout<<”5 not greater”; int b[5]={};, which of the following

a. 5 not greater b. prints nothing is true?


c. syntax error d. = omitted a. both are initialised with zeros
10. Given x=2, y=2, and z=3. The b. the elements of a are undetermined

condition in if((y==x))&&(x==z)) c. b is an empty array

evaluates to d. their highest index is 5


a. True. b. False. 17. Arguments may be passed to functions
11. The do…while control structure is a either by ……………..
………… a. value and literal
a. pre-test loop. b. post-test loop. b. value and reference
c. recurring loop d. selection loop c. value and parameters
12. The highest index of a 7X10 array is d. return type and parameters
……… 18. Variables that can hold memory addresses
a. 7, 10. b. 10, 7. are called…………

c. 6, 9. d. 9, 6. a. address operators.b. linkers.


c. reference variables. d. pointers.
13. The OOP concept that enables the use of
19. \n which denotes new line is a(n)
same function on different types of
…………….
objects is ….
a. escape sequence b. stream operator
a. polymorphism. b. inheritance.
c. statement d. header file
c. encapsulation. d. data abstraction
20. In which of the following are the integer
14. In OOP objects communicate with each
data types arranged in order of size?
other through their ………………
a. int, short int, long int.
functions.
b. short int, long int, int.
a. member b. abstract
c. long int, int, short int.
c. internal d. interface

2
d. short int, int, long int. a. prints nothing b. Empty list
21. The expression 5%2.0 will results to c. Full list d. both b and c
……. 28. The statement, return 0; in main
a. 1 b. 1.0 functions is mandatory for all C++
c. 2 d. an error programs.
22. Member functions are functions defined a. True b. False
within the body of ……… … . 29. Given x = 5 and y = 7. Which of the
a. loops following results to a change in value of
b. classes y?
c. subclasses interface a. x = y++; b. y = 17 %
d. encapsulated code 10;
23. If x=2, cout<<x++; prints ………. . c. y = x + 2; d. x = y – 2;
a. 2 b. 3 c. 1 d. 2++ 30. Arguments passed to functions by value
24. Given that x=2 and y=4, the can either be ………… .
statement; cout<<”x*y”; will return a. literals b. variables
……….. . c. expressions d. a, b, and/or c
a. 2*4 b. 8 31. Arguments passed to a function must be
c. x*y d. an error of the same type as its parameters.
25. ++ and -- are called unary operators a. True b. False
because they ……….. 32. In the switch(expression){...}
a. take one operand at a time selection statement, expression must
b. add or subtract 1 from a value always evaluate to …… .
c. use unit expression a. numeric value
d. operate on only integers b. floating-point number
26. Pick the odd one out. c. integer
a. && b. != c. || d. ! d. b or c
27. What is the output of the following code 33. The operator >> used with the cin object
segment? is called a(n) ………. operator.
int wordcnt=0; a. extraction b. insertion
if(wordcnt=0)
c. read-in d. get-input
cout<<”Empty list”<<endl;
else
cout<<”Full list”<<endl;

3
34. In order to enable a program to accept for(int a = 0; a < 4; ++a)
for(int b = 0; b < 4; ++b)
multiple word names such “Jonas Smith”
cout<<a<<" "<<b<<" ";
as input, the …... function should be used.
cout << endl;
a. string buffer b. getline a. 16 b. 8 c. 4 d. 0
c. insertion d. cin 40. Standard numeric codes used to represent
35. Unless otherwise specified arguments are alphabets are called …………. .
passed to functions by ………. . a. standard codes b. constants
a. address b. value c. Unicode d. bar codes
c. reference d. b and c only 41. A variable that is known to all functions
36. When an if statement occurs within either within a file is said to be ………………. .
the if or else clause of another if a. exposed b. general
statement, it is known as a ………. if . c. global d. worldly
a. self-contained b. layered
c. nested d. sheltered 42. A translator that notes whether you have
37. What is the output of the following code used a language correctly might be called
segment? a ……. .
int x = 7, y = 15;
a. thesaurus b. compiler
if(x < 0 || y < 0)
x = 25; c. coder d. decoder
y = 45; 43. A Standard Library file is synonymous to
cout << x << ", " << y << endl; a Header file.
a. 7, 15 b. 7, 45 a. True b. False
c. 25, 15 d. 25, 45 44. The process of combining two or more
38. The code extract below implements a(n) stings using the operator + is called?
………… loop. a. addition b. concatenation
int number = 1;
c. joining d. arithmetic
while(number <= 10){
operation
cout << number << endl;
} 45. The process of correcting errors in a
n++; program’s source code is referred to as?
a. recursive b. sequential a. checking b. compiling
c. finite d. infinite c. maintenance d. debugging
39. How many times does the loop body in 46. Comments in a program’s code are
the following code execute? executed at run time?

4
a. True b. False 49. Which of the following is/are attribute(s)
47. long int, float, and int are all of preprocessor directives?
real numeric data types. a. they begin with #
a. True b. False b. terminates with a semi column
48. All user-defined functions in C++ c. are executed in the main function
programs are executed by calling them in d. a and b only
the ……… 50. Which of the correctly declares and
a. preprocessor directive. initialises a variable of type char?
b. standard library files. a. char=’z’; b. char c=z;
c. main function. c. char c=’z’; d. char
d. std namespace ==’z’;

Dr. S. A Salifu

5
6

You might also like