Sem 2 1516

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

ll

CONFIDBNTIAL

UTHM
Unlversltl filn Husseln Onn fHalapla

UNTVERSITI TTIN HUSSEIN OI\N MALAYSIA

FINAL EXAIVIINATION
SEMESTERII
sEssroN 20rst2016

COURSE NAME : COMPUTER PROGRAMMING


COURSE CODE : BFC 20802
PROGRAMME CODE : BFF
EXAMINATION DATE : JUNE / IULY 2016
DURATION : 2 HOURS 30 MINUTES
INSTRUCTION : l. ANSWERALL QUESTIONS IN
SECTION A AND B.
2. CHOOSE ONLY ONE (r)
QUESTION IN SECTION C

THIS QITESTION PAPERCONSISTS OF BIGHT (S) PAGES

CONFIDENTIAL
a\

,l

CONFIDENTIAL BFC 2A8A2

SECTION A

Ql Please answer T (True) or F (False).


(10 marks)

Questions TRUE FALSE


a ROM stands for Read-only memory.
b RAM & ROM enable a computer to send and receive dat4
instruction and information.

c Source code of the program can be compiled even syntar error is


found, which is the advantage of using C# language as compared
to C language.

d Manipulator "endl" is used to advance the cursor to the beginning


of the next line.
e Basic types of control structure are sequential, selection and
repetition.
f The following code will not give an elror.

Int main 0
{
const double G:9.81;
double weighg mass
cout
cin
weight-mass*G
cout << "The weight of this object is" ( weight
return 0;
)

g The flowchart for selection structure is as shown

h Any of the expressions followed by a semicolon are variables.

I Binary nunbers are 10101000023010.

j Flags is a variable that signals a condition.

CONFIDENTIAL
CONT'II}ENTIAL BFC 20802

SECITON B

Insfucti@: Answer AI,L qr$ions.

Q2 Sfiate utheltcr fu fonowing vuiable nme are valid c invati4 If thcy are invalid, state
the reason.
(6 madrs)

a3 Givo x: 55, what ae &e values of each oftb following e,xprassions.


(a marks)
{r

\. I

COI\TFIDENTIAL BFC 2AtO2

a4 Cmverttbfolburing jf statmttoflowchart
(5 ma*s)

if (x::f )
cout((xi
else
cout((Y

aS Trace all errors in the following program.


(5 marks)

1- / lPxogram 2
2 #include <iostem>
3 #include (iomanip>
4 using namespace std;
5 int nain ( )
6{
7 double numL, numz total;
B numL : 3;
9 num2 : L.32;
L0 total : numl + numz
11- cout
L2 cout
13 return 0;
L4

4
CONIII}ENTIAL
CONFIDENTIAL BFC 2A802

(}6 Definetbc CIUSad &awaflowc,hart forthe foflowingpnogram.


(10 marks)

Prugrem Code Outpnt


#include <iostream>
using namespace std;
int main()
{
int count : 5;
cout
count++;
cout
++count;
count
cout
cout
cout
cout
cout
count:count*3;
cout
return 0;

Q7 Write a single C+ statement or line that accmpli$es each ofth followings:

(a) Assign the divisiom openator of variables P and A to variable o.

(1 mark)

(b) Print th message "Total for three diglts".

(1 mark)

(c) Instead of a - a + l, w€ Gan unite using increment operator as

(l ma*)
(d) Inpr$ fonintegervahs fim frc keybord i6s integervriables q b, c andd"

(l mark)

(e) Add x with 2, square root it and stored into y.


:
I

(l mark)

CONFIDENTIAT
CONFIDENTIAL BFC 2A802

Q8 Based on the given flowchart identifr the output of the average of odd numbers from I
to 9. Construct the algorithm based on the flow chart.
(10 marks)

a9 Define the conditional statement and give a suitable example for it.
(5 marks)

Q10 write a c.* program to find the output of the following series:

xn
sum:R-d-*.tt**,'*
'
5! 7!'9l '(n+ZI

(10 marks)

CONF'IDENTIAL
CONFIDBNTIAL BFC 20802

SECTION C

Qr1 Conshrct a flowchart and write a complete Cr-+ code which will ask user to key in the
pH level of a wats sample to find out its pH range and biological effwts according to
Teble I to decid€ whether a solution is very acidig acidig neutaf alkaline or v€ry
alkaline.

(30 marks)

Q12 Creafie a flowchartaadwrite acomplete C+ codetbatcalculatesthe loan information of


a car loan as shown in Trble 2. The flowchart aod C++ code should be able to prcvide
the user to enter the amormt and the number of years of the loan. Each loan will be
charged n'ith 3% intrest per year.

(30 marks)

-Ehln oFQUESTIONS-

7
CONTIDENTIAL
f{
I

.ita
Ir

COFTtr'II}ENTIAI BFC 2WO2

1 SESSKIN : SEM n / 20154016 PRffiCOIIE: BFF


COURSECODE : BFC zOWz

Tebb I
ptrrrge Ilrpc of solrtion @|crtcffotcs
0-2 Veryacidic Allfisdtu
3{ Acidic mostfiSdie
7 Neuhal Qptimrm formmtfish
t-l I Alkaline Mo$fiSdi€
12-14 Veryatkalire AllfiSdie

Trb'b2

Enter the amqrnt of loan: 9lX[0


Entsr &e number ofyears: T

LOAI{ INFORMATION:

Totallnffi :RlI 13900.00


TotalPalment : RM l08qx)
Mmthlyhlment :RM l2lreA3

CONTr'II}ENTIAL

You might also like