INIVERSITy OF ENERGY AND NATURAL RESOURCES, SUNYANI, GHANA
SCHOOL OF SCIENCES
DEPARTMENT OF COMPUTER SCIENCE AND INFORMATICS
LEVEL 10O END OF FIRST SEMESTER EXAMINATIONS 2018/2019
DIP. (COMPUTER SCIENCE / INFORMATION TECHNOLOGY)
DCSC 101: PRINCIPLES OF PROGRAMMING
December, 2018
ZAKNATION
Materials Required: Pens, Caleulator and Pencil
Time: 2 Hours
Instructions
WISHING YOU SUCCESS IN
Answer all questions in PART I, and II
YOUR EXAMS.
MAWULY CARES
PARTI
CHOOSE THE CORRECT ANSWER FROM THE OPTIONS LETTERED A -D
BY CIRCLING THE CORRECT ANSWER
A sequence of numeric codes that contains the required data to be
instructs the computer to perform a operated on.
particular task is. a. Operator
Assembly code b. Operation
Assembler C. Op- code
Object code d. Operand
Machine language code 3. The programming
is the art of an concept diotates alternative paths or
operation used to specify the sequence in à program.
aadress of the memory location that a. Syntax
b. Selection
11Page E . Q U A YSON/N.S.AWARAT'
ON
7. How many times will
C. Sequence
pseudocode below output the
d. Iteration
for a of A
4. In developing a pseudocode
execution A 1;
an alternative
program, WHILE( A < 5)
achieved by the
path could be
DO Print A;
except
following
A A;
a. IF statement ENDWHILE;
b. IF.... Else statement
a. 5
C. WHILE
b. 4
d. IF ... Else IF statement
C. 3
5. The following could be used in
d. None of the Above
executing a block of code repetitively
8. How many times will
except
pseudocode below output the -
a. WHILE
b. 'FOR of A
c. DO WHILE A 1;
d. Switch DO
6. How many times
the will Print A
pseudocode below output the value A A+ 3;
of A;
WHILE( A > 5)
A 1;
WHILE( A < 5) a. 5
DO Print A; b. 4
A A+2; c. 3
WISHING YOU d. 1
ENDWHILE; SUCCESS IN 9.
Select the invalid variable
a. 5 YOUR EXAMS. from the following;
b. 4 MAWULY a. myVariable
C. 3 CARES
b. sum
d. 2
C. number
2 Page
E. QUAYSON/N.S.AWARAYT
7. How many
times will
C. Sequence pseudocode below output the.d
d. Iteration
for a
of A
4. In developing a pseudocode
execution
A 1; Vo
an alternative
program,
the WHILE( A < 5) a
path could be
achieved by
DO Print A; b
except
following A = A; C-
a. IF statement ENDWHILE;
b. IF Else statement
a. 5
....
C. WHILE
b. 4
d. IF..... Else IF statement
C. 3
could be used in
5. The following d. None of the Above
executing a block of code repetitively
8. How many times will
except
pseudocode below output the r
a. WHILE
of A;
b. FOR
C. DO WHILE A 1;
d. Switch DO
6. How many times will the Print A
pseudocode below output the value A A+ 3,
of A
WHILE( A> 5)
A 1;
WHILE A < 5) a. 5
DO Print A; b. 4
WISHING YOU
A A+2 SUCCESS IN YOUR C. 3
d. 1
ENDWHILE; EXAMS.
a. 5
MAWULY CARES 9. Select the invalid variable
from the following
b. 4
a. myVariable
C. 3
b. sumn
d. 2
C.number
21 Page
E. QUAYSON/N.S.AWARAY
a. Iterator
b. Accumulator
d. lntereßt
valid
following
is a
of the C. Operator
Which
d. Counter
v a r i a b l e n a m e ?
computational
portion of a
15. The
a . D . O . B
the kind of
b . X _ s q u a r e d
which defines
operation
operation to undertake is the
C. 5star
d. int
is an invalid
the following
1Whichof a. Iterator
variable initialization.
b. Sequence
a. intnuml =5
C. Operator
AB'
int letter
=
b. d. Op- Code
5005.45
C. double salary
=
structure, the
16. In a loop
float f= 1.4 statement forcefully
d.
which of the following loop
2. In cause the exiting or termination of
code guaranteed to
structures is the
even though the loop.
execute at least once
a. Exit
the condition is False.
b. Terminate
a. For loop
c. Break
b. While loop
d. Continue
C. Do While loop
17. In a loop structure, the
d. All the above
statement causes a
3. A variable that is used to keep
track of the number of iterations is set of instructions to be skipped and
the control is given to the next
called
a. Iterator iteration index.
b. Accumulator a. Skip
c. Operator b. By pass
d. Counter C. Continue
. The variable that keeps the current d. Move To
accumulated value of a group o 18.Which of the following is nota
itemsis called arithmetic operator?
age
Q U A YSON/N.S.A WA RA YI
22. Which of the following is
a. relational operator?
Afte
b.+ a. = =
que
C. b. I= valu
d. C. a.
of the
19. What would be the value
d. <= b.
division operation
quotient in a
23. What will be the output C.
dividend is 5 and the
where the
d.
3 if the quotient,
dividend logical expression, !( (y <
3)
divisor is W
and divisor are double data type. 7)) ify =9
a. Unknown op
a. 5
val
b. False
b. 3
tr
C. 1 C. True
a.
d. 1.6666 d. !Error
b.
20. What would be the value of the 24. What will be the output d
quotient in a division operation expression, (x+1) >2 | | (x+1a
where the dividend is 5 and the if x = -5.
divisor is 3 if the quotient, dividend a. Unknown
Op
and divisor are integer data type. b. False
a. 5
C. True
b. 3
d. !Error
C. 1
25.
d. 1.66666
Assuming that initial values of b
and count variables
21. Willie want are 0 an
to
perform
arithmetic operation such
an
respectively, what will be
that he
resultant value of
gets the remainder as a result.
sum in
Which of the expression below;
operators should he
use? sum sum +
(++count)
a. *% a. 0
b. % b. 10
C. %/
C. 11
d.
d. 12
4|Page
WISHING YOU SUCCESS IN YOUR EXAMS.
MAWULY CARES EQuA YSON/N.S. A WARA
YI
a. namespaceid::operator
execution of the code in b . n a m e s p a c e , o p e r a t o r
the
be the
After
5. what will C. namespace#operator
25 above,
1estion of the mentioned
qau
d.
t es
count? none
the ariable
value
in
31. What is the output of program
a . 12 code below?
b. 0
int n;
for (n = 5; n > 0; n--)
10
C.
1. 11 c o u t << n,
of the following logical if (n = = 3)
7 . Which
will produce a True output break;
anerator
and only if both inputs are
value if a. 543
b. 54
true?
C. 5432
a. OR
d. 53
b. NOT
32. What is the output of the program
C. NAND code below?
d . AND
the following logical int a;
of
8. Which a = 5 + 3 * 5;
False output
operator will produce
a Cout << a,
only if both inputs are a. 35
value if and
b. 20
false?
C. 25
a. OR d. 30
SUb. NOT 33. Which data type is used to
represent the absencee of
d c. NAND
parameters?
d . AND
a. int
29. Which of the following logical b. short
operator is a unary operator? C. Void
d. float
a. OR
34. What is the output of this
b. NOT
program?
C. NAND
int a, g, b; b = 20; a = 35; g
d. AND
65;
30. What is the general syntax 1or cout << b <<a << g
accessing the namespace variableP
age E. QUA YSON/N.S.A WA RA "
S
d. None of the above.
a = 50;
38. Which of the following state A
cout << a << g
a. 2035655065
correctly assigns the sum o NS
variable midsem and exams
b. 2035655035
store the result in a variable tot
c. 2035635065
a. Total = midsem + exams
d. none of the mentioned
b. tota= = m i d s e m +exams;
35. What type of comments does ct+
C. total = midsem +examns;
support?
a. single line d. total+=midsem +examms
b. multi line 39. Which of the following is ess
C. single line and multi-line statement type for desc
d. none of the mentioned algorithms?
36. Which of the following is a a. Sequence
correct comment? b. Selection
a. */ Comments */ C. Repetition
b. **
Comment **
d. All the above
c./* Comment */ 40. Which of the following com
d. { Comment} moves the cursor to the start
next line?
37. Which of the following statements a. cout<<;
correctly display the data held in b. cout<<endOfLine;
variable total? C. cout<<'endl';
a. Cout<<"total"; d. none of the above.
b. Cout>>total;
c. Cout>>'total';
ZAKNATION
WISHING YOU SUCCESS IN YOUR EXAMS.
MAWULY CARES
ARTII
QUESTIONS IN THIS SECTION
TER ONLY TWO (2) that will take
take aa
VS wants to develop an algorithm
brother
younger number
Your you
Vour number is an even
1.
input and output whether the
a1tmber (N) as an
n
or odd number.
[4 marks]
above algorithm.
pseudocode for the
alWrite the [4 marks]
for the above algorithm.
hlDrawa
flowchart
programming language.
drawbacks of the first generation
cWrite two (2) 2 marks]
such as the principal, rate
c++ that accepts inputs
a program i n The simple interest
2. a) A wTite the simple interest.
and time and computes
of interest,
is computed as;
interest = (principal X rate of interest x time)/100
simple below:
as the sample output
should be represented
The output
Principal: 50000
Input the Interest: 22
the Rate of 5 marks]
Input
Time: 2.5
Input the
its
a number a s input and prints
in c++ that takes
Write a program
b)
multiplication
table up to 10.
Sample Output:
number: 4 WISHING YOU SUCCESS IN
Input a
4 x
1 4 YOUR EXAMS.
4x2 8 MAWULY CARES
12
4 x3
4x 10 = 40 5 marks]
YI
W A R A
A
E. UA YSON/N.
11Page
pseudocode
5 mark
flowchart
below to a
a C o n v e r t
the
Start
Set sum =0
nput r
Set i-1
No
jcn
Yes
Input number
Print sum
sum = sum+ mumber
i=i+1 Stop
variables and X, Y and Z are of type dou
A, B and C are integer
b) Given that and 20.0 respecti
a program are 20, 5, 10, 2.5, 1.0
If their current values in
then what will be the output
of the following expressions.
[1 mark
i) 1+A* C/B% 2+1
[1 mark
i) A/B* X -Y
ii) Z* B/C-X *A
[1 mark]1
c) What is the output from the code segment below? [2 marks
int x = 1, y = 0;
if (x> 0 88 y < 0)
WISHING YOU SUCCESS IN
YOUR EXAMS.
x = y = 23;
MAWULY CARES
cout << <<""
x <<
y << endl;
81Page WARA
E. QUA YS ON/N. S. A