SlideShare a Scribd company logo
CPPH501 – PAPER A. (2019 S1)
1
YEAR:
Student Number
Surname & Initials
2019
SEMESTER:
ASSESSMENT:
1
A
SUBJECT NAME: Computer Programming 1
SUBJECT CODE: CPPH501
QUALIFICATION(S): D3IP13 /INDUSTRIAL PHYSICS
PAPER DESCRIPTION: COMPUTER
BASED
DURATION: 3 HOURS PAPER: ONLY
SPECIAL REQUIREMENTS
 NONE
 NON-PROGRAMMABLE POCKET CALCULATOR
 SCIENTIFIC CALCULATOR
 COMPUTER ANSWER SHEET
 GRAPH PAPER
 DRAWING INSTRUMENTS
OTHER: COMPUTER
INSTRUCTIONS TO CANDIDATES: ANSWER ALL QUESTIONS
THIS TEST IS TO BE ANSWERED ON https://mytutor.tut.ac.za
WHEN YOU ARE DONE. GIVE YOUR ANSWER SCRIPT BACK TO THE
INVIGILATOR AND SUBMIT YOUR FILE.
TOTAL NUMBER OF PAGES INCLUDING COVER PAGE: 12
TOTAL NUMBER OF ANNEXURES: 0
EXAMINER: W BHEBE FULL MARKS: 96
MODERATOR: A KHOZA TOTAL MARKS: 96
STUDENT TOTAL: ___
STUDENT %: ___
Tshwane Universit)
of Technology
CPPH501 – PAPER A. (2019 S1)
2
QUESTION 1 [10]
STATEMENT TRUE FALSE
Theory
1.1 The float and double data types in C++ store real numbers.
1.2 The condition in the selection structure specifies the decision you are
making and is phrased so that it results in either a true or false answer
only.
1.3 The repetition structure is used to repeatedly process one or more
program instructions until some condition is met, at which time the
structure ends.
1.4 A function header in a C++ program does not end with a semicolon.
1.5 You cannot include actual arguments when you call a void function.
1.6 A repetition structure can only include one instruction.
1.7 To use the predefined function sqrt(), the program must include
the header file cmath.
1.8 The output of the statement:
cout << pow(3.0, 2.0) + 5 << endl; is 14.
1.9 The following is an example of a valid function prototype:
void calc(double, double, double &, double &);
1.10 The built-in srand function is an example of a value-returning
function.
CPPH501 – PAPER A. (2019 S1)
3
QUESTION 2 [10]
In each of the following statements, choose the only correct answer.
2.1 The ____ structure makes a decision and then takes an appropriate action based on
that decision
a. selection
b. case
c. repetition
d. iteration
e. None of the above
2.2 ____ is an example of a syntax error.
a. cout<<’Hello’;
b. cin>>raiseRate;
c. cout<<”New Pay :”<<newPay<<endl;
d. average =number1 +number2/2;
e. None of the above
2.3 The ____ statement tells the computer to leave the switch statement at that point.
a. break
b. continue
c. stop
d. case
e. None of the above
2.4 If the default clause is not the last clause in the switch statement, you will need to
Include a ____ statement at the end of the clause to stop the computer from
processing the instructions in the next case clause.
.
a. continue
b. break
c. stop
d. switch
e. None of the above
2.5 A loop that processes its instructions indefinitely is referred to as a(n) ____ loop.
a. infinite
b. non sentinel
c. accumulating
d. incorrect
e. None of the above
CPPH501 – PAPER A. (2019 S1)
4
2.6 Every C++ program contains at least one function: ____.
a. main()
b. pow()
c. return()
d. rand()
e. None of the above
2.7 In standard C++, the random number generator is a built-in function named ____.
a. rand()
b. random()
c. rnd()
d. rndm()
e. None of the above
2.8 When a function definition appears below the main () function, you must enter a
function ____ above the main() function.
a. argument
b. parameter
c. prototype
d. declaration
e. None of the above
2.9 To pass a variable by reference in C++, you include a (n) ____ before the name of
the corresponding formal parameter in the receiving function’s header.
a. *
b. @
c. #
d. &
e. None of the above
2.10 ____ is an example of a valid function call.
a. void calc(double, double, double &, double &);
b. calc(salary, raiseRate, raise, newSalary);
c. void calc(double current, double rate, double &increase, double &pay)
d. calc(salary, raiseRate, &raise, &newSalary);
e. None of the above
CPPH501 – PAPER A. (2019 S1)
5
QUESTION 2 (MULTIPLE CHOICE)
2.1 a b c d e
2.2 a b c d e
2.3 a b c d e
2.4 a b c d e
2.5 a b c d e
2.6 a b c d e
2.7 a b c d e
2.8 a b c d e
2.9 a b c d e
2.10 a b c d e
CPPH501 – PAPER A. (2019 S1)
6
QUESTION 3 [21]
3.1 What is an escape character? Give an example. [2]
3.2 Propose an appropriate prototype of a function that will return the higher of any two
numbers passed as argument to the function [4]
3.3. Write C++ statements for the following: [3]
𝑝𝑝 = �𝑎𝑎2 + 𝑏𝑏2
CPPH501 – PAPER A. (2019 S1)
7
3.4. Write C++ statements for the following: [3]
𝑠𝑠𝑠𝑠𝑠𝑠 =
𝑎𝑎(𝑟𝑟𝑛𝑛
− 1)
𝑟𝑟 − 1
3.5 Explain in your own words, the term ‘modularity’ [3]
CPPH501 – PAPER A. (2019 S1)
8
3.6 Study the following code and rewrite the program using a “for” loop [6]
Write your answer in the space provided below
int number = 1;
do
{
cout << number <<
endl; number++;
} while (number <= 10);
CPPH501 – PAPER A. (2019 S1)
9
QUESTION 4 [16]
Create a program that displays a series of the first 10 Fibonacci numbers (1, 1, 2, 3, 5, 8,
13, 21, 34, and 55). Notice that, beginning with the third number in the series, each
Fibonacci number is the sum of the prior two numbers. In other words, 2 is the sum of 1
plus 1, 3 is the sum of 1 plus 2, 5 is the sum of 2 plus 3, and so on. Write two versions of
the code: one using the for statement and the other using the while statement. Enter
the C++ instructions into a source file named Question5.cpp. Add appropriate comments
and any additional instructions required to execute your program. Note: the Fibonacci
numbers should appear twice on the screen. Refer to figure 4.1 for sample output.
Figure 4.1
QUESTION 5 [6]
Write a C++ for loop that will produce the output in figure 5.1. Include appropriate
comments and any additional instructions required to execute your program.
Figure 5.1
I C:Usersraphirits.TUTD~sktopSickT~st2D~bugSickT~st2.~x~
i s playing t e the FIRST 10 i onacci
umbers us ing [for s tatement]
i s playing the the FIRST 10 Fibonacci
umbers us ing [while s t a tement]
any key to continue . . . _
Squat'e
4
16
36
64
100
any key
Cube
8
64
216
512
1000
to continue
V
CPPH501 – PAPER A. (2019 S1)
10
Question 6 [23]
Create a program for the sales manager at Computer Haven, a small business that offers
motivational seminars to local companies. Table 6-1 shows the charge for attending a
seminar. Notice that the charge per person depends on the number of people the company
registers. For example, the cost for four registrants is R5 761.32; the cost for two registrants
is R4 321.0. The program should allow the sales manager to enter the number of registrants
for as many companies as needed. When the sales manager has finished entering the data,
the program should calculate and display the total number of people registered, the total
charge for those registrants, and the average charge per registrant. For example, if one
company registers four people and another company registers two people, the total number
of people registered is six, the total charge is R10 082.32, and the average charge per
registrant is R1680.38.
Number of people a
company registers
Charge per person (R)
1 – 3 2160.50
4 – 9 1440.33
10 or more 1296.30
Table 6.1
Include necessary statements to compile and run your program. See figure 6.1 for sample
output.
CPPH501 – PAPER A. (2019 S1)
11
Figure 5-1
QUESTION 7 [10]
Write, compile and run a C++ program to input the following values into an array
named velocity: 10.95, 16.32, 12.14, 8.33, 45.20, 36.45, 7.89, 12.35 and 11.54.
After your data has been entered have your program display the values.
first coApany (negative nuAber to stop the prograA): 4
registered by the next coApany (negative nuAber to stop the prograA): 2
registered by the next coApany (negative nuAber to stop the prograA): -5
otal nuAber of registrants: 6
otal charge for all registrants: R10082.32
uerage charge per registrant: R1680.39
registered by the next COApany (negative
registered by the next COApany (negative
registered by the next COApany (negative
registered by the next COApany (negative
registered by the next COApany (negative
registered by the next COApany (negative
registered by the next COApany (negative
registered by the next COApany (negative
registered by the next COApany (negative
otal nuAber of registrants: 50
otal charge for all registrants: R?561?.39
verage charge per registrant: R1512.35
nm11ber to stop the pl"Ogl"aA): 8
nm11ber to stop the pl"Ogl"aA): 3
nm11ber to stop the pl"Ogl"aA): 1
nm11ber to stop the pl"Ogl"aA): 3
nm11ber to stop the pl"Ogl"aA): 4
nm11ber to stop the pl"Ogl"aA): ?
nm11ber to stop the pl"Ogl"aA): 10
nm11ber to stop the pl"Ogl"aA): 9
nm11ber to stop the pl"Ogl"aA): -1
y
CPPH501 – PAPER A. (2019 S1)
12
INSTRUCTIONS TO STUDENTS
- All codes must be copied into a single file (MS word file, or any other format
recommended by the lecturer)
- The file name must match your student number
- Student name and student number must be written at the top of the submitted file!!
- All practical work must be submitted on myTutor
- Make sure the lecturer or invigilator has collected your project before leaving the
venue!

More Related Content

What's hot

B.Com 1year Lab programs
B.Com 1year Lab programsB.Com 1year Lab programs
B.Com 1year Lab programs
Prasadu Peddi
 
VTU 1ST SEM PROGRAMMING IN C & DATA STRUCTURES SOLVED PAPERS OF JUNE-2015 & ...
VTU 1ST SEM  PROGRAMMING IN C & DATA STRUCTURES SOLVED PAPERS OF JUNE-2015 & ...VTU 1ST SEM  PROGRAMMING IN C & DATA STRUCTURES SOLVED PAPERS OF JUNE-2015 & ...
VTU 1ST SEM PROGRAMMING IN C & DATA STRUCTURES SOLVED PAPERS OF JUNE-2015 & ...
vtunotesbysree
 
Pointers in Programming
Pointers in ProgrammingPointers in Programming
Pointers in Programming
HamadZia1
 
C programming 28 program
C programming 28 programC programming 28 program
C programming 28 program
F Courses
 
Simple c program
Simple c programSimple c program
Simple c programRavi Singh
 
C - Programming Assignment 1 and 2
C - Programming Assignment 1 and 2C - Programming Assignment 1 and 2
C - Programming Assignment 1 and 2
Animesh Chaturvedi
 
I PUC CS Lab_programs
I PUC CS Lab_programsI PUC CS Lab_programs
I PUC CS Lab_programs
Prof. Dr. K. Adisesha
 
important C questions and_answers praveensomesh
important C questions and_answers praveensomeshimportant C questions and_answers praveensomesh
important C questions and_answers praveensomesh
praveensomesh
 
C Programming
C ProgrammingC Programming
C Programming
Sumant Diwakar
 
C language questions_answers_explanation
C language questions_answers_explanationC language questions_answers_explanation
C language questions_answers_explanation
srinath v
 
Data structures question paper anna university
Data structures question paper anna universityData structures question paper anna university
Data structures question paper anna universitysangeethajames07
 
C program report tips
C program report tipsC program report tips
C program report tipsHarry Pott
 
Lab. Programs in C
Lab. Programs in CLab. Programs in C
Lab. Programs in C
Saket Pathak
 
CP Handout#4
CP Handout#4CP Handout#4
CP Handout#4
trupti1976
 
Lab manualsahu[et&amp;t]
Lab manualsahu[et&amp;t]Lab manualsahu[et&amp;t]
Lab manualsahu[et&amp;t]
Vivek Kumar Sinha
 
Itp practical file_1-year
Itp practical file_1-yearItp practical file_1-year
Itp practical file_1-year
AMIT SINGH
 
Few Operator used in c++
Few Operator used in c++Few Operator used in c++
Few Operator used in c++
sunny khan
 

What's hot (20)

B.Com 1year Lab programs
B.Com 1year Lab programsB.Com 1year Lab programs
B.Com 1year Lab programs
 
VTU 1ST SEM PROGRAMMING IN C & DATA STRUCTURES SOLVED PAPERS OF JUNE-2015 & ...
VTU 1ST SEM  PROGRAMMING IN C & DATA STRUCTURES SOLVED PAPERS OF JUNE-2015 & ...VTU 1ST SEM  PROGRAMMING IN C & DATA STRUCTURES SOLVED PAPERS OF JUNE-2015 & ...
VTU 1ST SEM PROGRAMMING IN C & DATA STRUCTURES SOLVED PAPERS OF JUNE-2015 & ...
 
Pointers in Programming
Pointers in ProgrammingPointers in Programming
Pointers in Programming
 
C lab-programs
C lab-programsC lab-programs
C lab-programs
 
week-3x
week-3xweek-3x
week-3x
 
C programming 28 program
C programming 28 programC programming 28 program
C programming 28 program
 
Simple c program
Simple c programSimple c program
Simple c program
 
C - Programming Assignment 1 and 2
C - Programming Assignment 1 and 2C - Programming Assignment 1 and 2
C - Programming Assignment 1 and 2
 
I PUC CS Lab_programs
I PUC CS Lab_programsI PUC CS Lab_programs
I PUC CS Lab_programs
 
important C questions and_answers praveensomesh
important C questions and_answers praveensomeshimportant C questions and_answers praveensomesh
important C questions and_answers praveensomesh
 
C Programming
C ProgrammingC Programming
C Programming
 
C language questions_answers_explanation
C language questions_answers_explanationC language questions_answers_explanation
C language questions_answers_explanation
 
Lab 1
Lab 1Lab 1
Lab 1
 
Data structures question paper anna university
Data structures question paper anna universityData structures question paper anna university
Data structures question paper anna university
 
C program report tips
C program report tipsC program report tips
C program report tips
 
Lab. Programs in C
Lab. Programs in CLab. Programs in C
Lab. Programs in C
 
CP Handout#4
CP Handout#4CP Handout#4
CP Handout#4
 
Lab manualsahu[et&amp;t]
Lab manualsahu[et&amp;t]Lab manualsahu[et&amp;t]
Lab manualsahu[et&amp;t]
 
Itp practical file_1-year
Itp practical file_1-yearItp practical file_1-year
Itp practical file_1-year
 
Few Operator used in c++
Few Operator used in c++Few Operator used in c++
Few Operator used in c++
 

Similar to Cpph exam a_2019_s1

COMP 122 Entire Course NEW
COMP 122 Entire Course NEWCOMP 122 Entire Course NEW
COMP 122 Entire Course NEW
shyamuopeight
 
Mid term sem 2 1415 sol
Mid term sem 2 1415 solMid term sem 2 1415 sol
Mid term sem 2 1415 sol
IIUM
 
c++ Question
c++  Questionc++  Question
c++ Question
Hamza4467
 
By Analyzing and Utilizing Jean Watson theory of caring, creat
By Analyzing and Utilizing Jean Watson theory of caring, creatBy Analyzing and Utilizing Jean Watson theory of caring, creat
By Analyzing and Utilizing Jean Watson theory of caring, creat
TawnaDelatorrejs
 
Comp 122 lab 3 lab report and source code
Comp 122 lab 3 lab report and source codeComp 122 lab 3 lab report and source code
Comp 122 lab 3 lab report and source code
pradesigali1
 
1 University of Leeds School of Computing Proced.docx
1 University of Leeds       School of Computing Proced.docx1 University of Leeds       School of Computing Proced.docx
1 University of Leeds School of Computing Proced.docx
jeremylockett77
 
Spring 2014 CSCI 111 Final exam of 1 61. (2 points) Fl.docx
Spring 2014 CSCI 111 Final exam   of 1 61. (2 points) Fl.docxSpring 2014 CSCI 111 Final exam   of 1 61. (2 points) Fl.docx
Spring 2014 CSCI 111 Final exam of 1 61. (2 points) Fl.docx
rafbolet0
 
1-Base-CaseTool KitChapter 11112118Note Calculations are automa
1-Base-CaseTool KitChapter 11112118Note Calculations are automa1-Base-CaseTool KitChapter 11112118Note Calculations are automa
1-Base-CaseTool KitChapter 11112118Note Calculations are automa
MartineMccracken314
 
1-Base-CaseTool KitChapter 11112118Note Calculations are automa
1-Base-CaseTool KitChapter 11112118Note Calculations are automa1-Base-CaseTool KitChapter 11112118Note Calculations are automa
1-Base-CaseTool KitChapter 11112118Note Calculations are automa
AbbyWhyte974
 
Sample Program file class 11.pdf
Sample Program file class 11.pdfSample Program file class 11.pdf
Sample Program file class 11.pdf
YashMirge2
 
LAB_MANUAL_cpl_21scheme-2.pdf
LAB_MANUAL_cpl_21scheme-2.pdfLAB_MANUAL_cpl_21scheme-2.pdf
LAB_MANUAL_cpl_21scheme-2.pdf
RavinReddy3
 
Pseudocode algorithim flowchart
Pseudocode algorithim flowchartPseudocode algorithim flowchart
Pseudocode algorithim flowchart
fika sweety
 
EC6612 VLSI Design Lab Manual
EC6612 VLSI Design Lab ManualEC6612 VLSI Design Lab Manual
EC6612 VLSI Design Lab Manual
tamil arasan
 
Capital budgeting techniques
Capital budgeting techniquesCapital budgeting techniques
Capital budgeting techniquesIan Isabel
 
M150 A Fall2010 T01
M150 A Fall2010 T01M150 A Fall2010 T01
M150 A Fall2010 T01
abdalodainat
 
Cp manual final
Cp manual finalCp manual final
Cp manual final
itprasad1237
 
Important C program of Balagurusamy Book
Important C program of Balagurusamy BookImportant C program of Balagurusamy Book
Important C program of Balagurusamy Book
Abir Hossain
 
CBCS 2018 Scheme I sem Lab Manual for 18CPL17
CBCS 2018 Scheme I sem Lab Manual for 18CPL17 CBCS 2018 Scheme I sem Lab Manual for 18CPL17
CBCS 2018 Scheme I sem Lab Manual for 18CPL17
manjurkts
 
Bis 311 final examination answers
Bis 311 final examination answersBis 311 final examination answers
Bis 311 final examination answers
RandalHoffman
 
C Programming Lab manual 18CPL17
C Programming Lab manual 18CPL17C Programming Lab manual 18CPL17
C Programming Lab manual 18CPL17
manjurkts
 

Similar to Cpph exam a_2019_s1 (20)

COMP 122 Entire Course NEW
COMP 122 Entire Course NEWCOMP 122 Entire Course NEW
COMP 122 Entire Course NEW
 
Mid term sem 2 1415 sol
Mid term sem 2 1415 solMid term sem 2 1415 sol
Mid term sem 2 1415 sol
 
c++ Question
c++  Questionc++  Question
c++ Question
 
By Analyzing and Utilizing Jean Watson theory of caring, creat
By Analyzing and Utilizing Jean Watson theory of caring, creatBy Analyzing and Utilizing Jean Watson theory of caring, creat
By Analyzing and Utilizing Jean Watson theory of caring, creat
 
Comp 122 lab 3 lab report and source code
Comp 122 lab 3 lab report and source codeComp 122 lab 3 lab report and source code
Comp 122 lab 3 lab report and source code
 
1 University of Leeds School of Computing Proced.docx
1 University of Leeds       School of Computing Proced.docx1 University of Leeds       School of Computing Proced.docx
1 University of Leeds School of Computing Proced.docx
 
Spring 2014 CSCI 111 Final exam of 1 61. (2 points) Fl.docx
Spring 2014 CSCI 111 Final exam   of 1 61. (2 points) Fl.docxSpring 2014 CSCI 111 Final exam   of 1 61. (2 points) Fl.docx
Spring 2014 CSCI 111 Final exam of 1 61. (2 points) Fl.docx
 
1-Base-CaseTool KitChapter 11112118Note Calculations are automa
1-Base-CaseTool KitChapter 11112118Note Calculations are automa1-Base-CaseTool KitChapter 11112118Note Calculations are automa
1-Base-CaseTool KitChapter 11112118Note Calculations are automa
 
1-Base-CaseTool KitChapter 11112118Note Calculations are automa
1-Base-CaseTool KitChapter 11112118Note Calculations are automa1-Base-CaseTool KitChapter 11112118Note Calculations are automa
1-Base-CaseTool KitChapter 11112118Note Calculations are automa
 
Sample Program file class 11.pdf
Sample Program file class 11.pdfSample Program file class 11.pdf
Sample Program file class 11.pdf
 
LAB_MANUAL_cpl_21scheme-2.pdf
LAB_MANUAL_cpl_21scheme-2.pdfLAB_MANUAL_cpl_21scheme-2.pdf
LAB_MANUAL_cpl_21scheme-2.pdf
 
Pseudocode algorithim flowchart
Pseudocode algorithim flowchartPseudocode algorithim flowchart
Pseudocode algorithim flowchart
 
EC6612 VLSI Design Lab Manual
EC6612 VLSI Design Lab ManualEC6612 VLSI Design Lab Manual
EC6612 VLSI Design Lab Manual
 
Capital budgeting techniques
Capital budgeting techniquesCapital budgeting techniques
Capital budgeting techniques
 
M150 A Fall2010 T01
M150 A Fall2010 T01M150 A Fall2010 T01
M150 A Fall2010 T01
 
Cp manual final
Cp manual finalCp manual final
Cp manual final
 
Important C program of Balagurusamy Book
Important C program of Balagurusamy BookImportant C program of Balagurusamy Book
Important C program of Balagurusamy Book
 
CBCS 2018 Scheme I sem Lab Manual for 18CPL17
CBCS 2018 Scheme I sem Lab Manual for 18CPL17 CBCS 2018 Scheme I sem Lab Manual for 18CPL17
CBCS 2018 Scheme I sem Lab Manual for 18CPL17
 
Bis 311 final examination answers
Bis 311 final examination answersBis 311 final examination answers
Bis 311 final examination answers
 
C Programming Lab manual 18CPL17
C Programming Lab manual 18CPL17C Programming Lab manual 18CPL17
C Programming Lab manual 18CPL17
 

Recently uploaded

Mammalian Pineal Body Structure and Also Functions
Mammalian Pineal Body Structure and Also FunctionsMammalian Pineal Body Structure and Also Functions
Mammalian Pineal Body Structure and Also Functions
YOGESH DOGRA
 
Lab report on liquid viscosity of glycerin
Lab report on liquid viscosity of glycerinLab report on liquid viscosity of glycerin
Lab report on liquid viscosity of glycerin
ossaicprecious19
 
Body fluids_tonicity_dehydration_hypovolemia_hypervolemia.pptx
Body fluids_tonicity_dehydration_hypovolemia_hypervolemia.pptxBody fluids_tonicity_dehydration_hypovolemia_hypervolemia.pptx
Body fluids_tonicity_dehydration_hypovolemia_hypervolemia.pptx
muralinath2
 
platelets_clotting_biogenesis.clot retractionpptx
platelets_clotting_biogenesis.clot retractionpptxplatelets_clotting_biogenesis.clot retractionpptx
platelets_clotting_biogenesis.clot retractionpptx
muralinath2
 
extra-chromosomal-inheritance[1].pptx.pdfpdf
extra-chromosomal-inheritance[1].pptx.pdfpdfextra-chromosomal-inheritance[1].pptx.pdfpdf
extra-chromosomal-inheritance[1].pptx.pdfpdf
DiyaBiswas10
 
Hemostasis_importance& clinical significance.pptx
Hemostasis_importance& clinical significance.pptxHemostasis_importance& clinical significance.pptx
Hemostasis_importance& clinical significance.pptx
muralinath2
 
Richard's aventures in two entangled wonderlands
Richard's aventures in two entangled wonderlandsRichard's aventures in two entangled wonderlands
Richard's aventures in two entangled wonderlands
Richard Gill
 
FAIR & AI Ready KGs for Explainable Predictions
FAIR & AI Ready KGs for Explainable PredictionsFAIR & AI Ready KGs for Explainable Predictions
FAIR & AI Ready KGs for Explainable Predictions
Michel Dumontier
 
Penicillin...........................pptx
Penicillin...........................pptxPenicillin...........................pptx
Penicillin...........................pptx
Cherry
 
Structural Classification Of Protein (SCOP)
Structural Classification Of Protein  (SCOP)Structural Classification Of Protein  (SCOP)
Structural Classification Of Protein (SCOP)
aishnasrivastava
 
PRESENTATION ABOUT PRINCIPLE OF COSMATIC EVALUATION
PRESENTATION ABOUT PRINCIPLE OF COSMATIC EVALUATIONPRESENTATION ABOUT PRINCIPLE OF COSMATIC EVALUATION
PRESENTATION ABOUT PRINCIPLE OF COSMATIC EVALUATION
ChetanK57
 
RNA INTERFERENCE: UNRAVELING GENETIC SILENCING
RNA INTERFERENCE: UNRAVELING GENETIC SILENCINGRNA INTERFERENCE: UNRAVELING GENETIC SILENCING
RNA INTERFERENCE: UNRAVELING GENETIC SILENCING
AADYARAJPANDEY1
 
general properties of oerganologametal.ppt
general properties of oerganologametal.pptgeneral properties of oerganologametal.ppt
general properties of oerganologametal.ppt
IqrimaNabilatulhusni
 
Comparative structure of adrenal gland in vertebrates
Comparative structure of adrenal gland in vertebratesComparative structure of adrenal gland in vertebrates
Comparative structure of adrenal gland in vertebrates
sachin783648
 
Predicting property prices with machine learning algorithms.pdf
Predicting property prices with machine learning algorithms.pdfPredicting property prices with machine learning algorithms.pdf
Predicting property prices with machine learning algorithms.pdf
binhminhvu04
 
justice-and-fairness-ethics with example
justice-and-fairness-ethics with examplejustice-and-fairness-ethics with example
justice-and-fairness-ethics with example
azzyixes
 
insect taxonomy importance systematics and classification
insect taxonomy importance systematics and classificationinsect taxonomy importance systematics and classification
insect taxonomy importance systematics and classification
anitaento25
 
Citrus Greening Disease and its Management
Citrus Greening Disease and its ManagementCitrus Greening Disease and its Management
Citrus Greening Disease and its Management
subedisuryaofficial
 
Orion Air Quality Monitoring Systems - CWS
Orion Air Quality Monitoring Systems - CWSOrion Air Quality Monitoring Systems - CWS
Orion Air Quality Monitoring Systems - CWS
Columbia Weather Systems
 
THE IMPORTANCE OF MARTIAN ATMOSPHERE SAMPLE RETURN.
THE IMPORTANCE OF MARTIAN ATMOSPHERE SAMPLE RETURN.THE IMPORTANCE OF MARTIAN ATMOSPHERE SAMPLE RETURN.
THE IMPORTANCE OF MARTIAN ATMOSPHERE SAMPLE RETURN.
Sérgio Sacani
 

Recently uploaded (20)

Mammalian Pineal Body Structure and Also Functions
Mammalian Pineal Body Structure and Also FunctionsMammalian Pineal Body Structure and Also Functions
Mammalian Pineal Body Structure and Also Functions
 
Lab report on liquid viscosity of glycerin
Lab report on liquid viscosity of glycerinLab report on liquid viscosity of glycerin
Lab report on liquid viscosity of glycerin
 
Body fluids_tonicity_dehydration_hypovolemia_hypervolemia.pptx
Body fluids_tonicity_dehydration_hypovolemia_hypervolemia.pptxBody fluids_tonicity_dehydration_hypovolemia_hypervolemia.pptx
Body fluids_tonicity_dehydration_hypovolemia_hypervolemia.pptx
 
platelets_clotting_biogenesis.clot retractionpptx
platelets_clotting_biogenesis.clot retractionpptxplatelets_clotting_biogenesis.clot retractionpptx
platelets_clotting_biogenesis.clot retractionpptx
 
extra-chromosomal-inheritance[1].pptx.pdfpdf
extra-chromosomal-inheritance[1].pptx.pdfpdfextra-chromosomal-inheritance[1].pptx.pdfpdf
extra-chromosomal-inheritance[1].pptx.pdfpdf
 
Hemostasis_importance& clinical significance.pptx
Hemostasis_importance& clinical significance.pptxHemostasis_importance& clinical significance.pptx
Hemostasis_importance& clinical significance.pptx
 
Richard's aventures in two entangled wonderlands
Richard's aventures in two entangled wonderlandsRichard's aventures in two entangled wonderlands
Richard's aventures in two entangled wonderlands
 
FAIR & AI Ready KGs for Explainable Predictions
FAIR & AI Ready KGs for Explainable PredictionsFAIR & AI Ready KGs for Explainable Predictions
FAIR & AI Ready KGs for Explainable Predictions
 
Penicillin...........................pptx
Penicillin...........................pptxPenicillin...........................pptx
Penicillin...........................pptx
 
Structural Classification Of Protein (SCOP)
Structural Classification Of Protein  (SCOP)Structural Classification Of Protein  (SCOP)
Structural Classification Of Protein (SCOP)
 
PRESENTATION ABOUT PRINCIPLE OF COSMATIC EVALUATION
PRESENTATION ABOUT PRINCIPLE OF COSMATIC EVALUATIONPRESENTATION ABOUT PRINCIPLE OF COSMATIC EVALUATION
PRESENTATION ABOUT PRINCIPLE OF COSMATIC EVALUATION
 
RNA INTERFERENCE: UNRAVELING GENETIC SILENCING
RNA INTERFERENCE: UNRAVELING GENETIC SILENCINGRNA INTERFERENCE: UNRAVELING GENETIC SILENCING
RNA INTERFERENCE: UNRAVELING GENETIC SILENCING
 
general properties of oerganologametal.ppt
general properties of oerganologametal.pptgeneral properties of oerganologametal.ppt
general properties of oerganologametal.ppt
 
Comparative structure of adrenal gland in vertebrates
Comparative structure of adrenal gland in vertebratesComparative structure of adrenal gland in vertebrates
Comparative structure of adrenal gland in vertebrates
 
Predicting property prices with machine learning algorithms.pdf
Predicting property prices with machine learning algorithms.pdfPredicting property prices with machine learning algorithms.pdf
Predicting property prices with machine learning algorithms.pdf
 
justice-and-fairness-ethics with example
justice-and-fairness-ethics with examplejustice-and-fairness-ethics with example
justice-and-fairness-ethics with example
 
insect taxonomy importance systematics and classification
insect taxonomy importance systematics and classificationinsect taxonomy importance systematics and classification
insect taxonomy importance systematics and classification
 
Citrus Greening Disease and its Management
Citrus Greening Disease and its ManagementCitrus Greening Disease and its Management
Citrus Greening Disease and its Management
 
Orion Air Quality Monitoring Systems - CWS
Orion Air Quality Monitoring Systems - CWSOrion Air Quality Monitoring Systems - CWS
Orion Air Quality Monitoring Systems - CWS
 
THE IMPORTANCE OF MARTIAN ATMOSPHERE SAMPLE RETURN.
THE IMPORTANCE OF MARTIAN ATMOSPHERE SAMPLE RETURN.THE IMPORTANCE OF MARTIAN ATMOSPHERE SAMPLE RETURN.
THE IMPORTANCE OF MARTIAN ATMOSPHERE SAMPLE RETURN.
 

Cpph exam a_2019_s1

  • 1. CPPH501 – PAPER A. (2019 S1) 1 YEAR: Student Number Surname & Initials 2019 SEMESTER: ASSESSMENT: 1 A SUBJECT NAME: Computer Programming 1 SUBJECT CODE: CPPH501 QUALIFICATION(S): D3IP13 /INDUSTRIAL PHYSICS PAPER DESCRIPTION: COMPUTER BASED DURATION: 3 HOURS PAPER: ONLY SPECIAL REQUIREMENTS  NONE  NON-PROGRAMMABLE POCKET CALCULATOR  SCIENTIFIC CALCULATOR  COMPUTER ANSWER SHEET  GRAPH PAPER  DRAWING INSTRUMENTS OTHER: COMPUTER INSTRUCTIONS TO CANDIDATES: ANSWER ALL QUESTIONS THIS TEST IS TO BE ANSWERED ON https://mytutor.tut.ac.za WHEN YOU ARE DONE. GIVE YOUR ANSWER SCRIPT BACK TO THE INVIGILATOR AND SUBMIT YOUR FILE. TOTAL NUMBER OF PAGES INCLUDING COVER PAGE: 12 TOTAL NUMBER OF ANNEXURES: 0 EXAMINER: W BHEBE FULL MARKS: 96 MODERATOR: A KHOZA TOTAL MARKS: 96 STUDENT TOTAL: ___ STUDENT %: ___ Tshwane Universit) of Technology
  • 2. CPPH501 – PAPER A. (2019 S1) 2 QUESTION 1 [10] STATEMENT TRUE FALSE Theory 1.1 The float and double data types in C++ store real numbers. 1.2 The condition in the selection structure specifies the decision you are making and is phrased so that it results in either a true or false answer only. 1.3 The repetition structure is used to repeatedly process one or more program instructions until some condition is met, at which time the structure ends. 1.4 A function header in a C++ program does not end with a semicolon. 1.5 You cannot include actual arguments when you call a void function. 1.6 A repetition structure can only include one instruction. 1.7 To use the predefined function sqrt(), the program must include the header file cmath. 1.8 The output of the statement: cout << pow(3.0, 2.0) + 5 << endl; is 14. 1.9 The following is an example of a valid function prototype: void calc(double, double, double &, double &); 1.10 The built-in srand function is an example of a value-returning function.
  • 3. CPPH501 – PAPER A. (2019 S1) 3 QUESTION 2 [10] In each of the following statements, choose the only correct answer. 2.1 The ____ structure makes a decision and then takes an appropriate action based on that decision a. selection b. case c. repetition d. iteration e. None of the above 2.2 ____ is an example of a syntax error. a. cout<<’Hello’; b. cin>>raiseRate; c. cout<<”New Pay :”<<newPay<<endl; d. average =number1 +number2/2; e. None of the above 2.3 The ____ statement tells the computer to leave the switch statement at that point. a. break b. continue c. stop d. case e. None of the above 2.4 If the default clause is not the last clause in the switch statement, you will need to Include a ____ statement at the end of the clause to stop the computer from processing the instructions in the next case clause. . a. continue b. break c. stop d. switch e. None of the above 2.5 A loop that processes its instructions indefinitely is referred to as a(n) ____ loop. a. infinite b. non sentinel c. accumulating d. incorrect e. None of the above
  • 4. CPPH501 – PAPER A. (2019 S1) 4 2.6 Every C++ program contains at least one function: ____. a. main() b. pow() c. return() d. rand() e. None of the above 2.7 In standard C++, the random number generator is a built-in function named ____. a. rand() b. random() c. rnd() d. rndm() e. None of the above 2.8 When a function definition appears below the main () function, you must enter a function ____ above the main() function. a. argument b. parameter c. prototype d. declaration e. None of the above 2.9 To pass a variable by reference in C++, you include a (n) ____ before the name of the corresponding formal parameter in the receiving function’s header. a. * b. @ c. # d. & e. None of the above 2.10 ____ is an example of a valid function call. a. void calc(double, double, double &, double &); b. calc(salary, raiseRate, raise, newSalary); c. void calc(double current, double rate, double &increase, double &pay) d. calc(salary, raiseRate, &raise, &newSalary); e. None of the above
  • 5. CPPH501 – PAPER A. (2019 S1) 5 QUESTION 2 (MULTIPLE CHOICE) 2.1 a b c d e 2.2 a b c d e 2.3 a b c d e 2.4 a b c d e 2.5 a b c d e 2.6 a b c d e 2.7 a b c d e 2.8 a b c d e 2.9 a b c d e 2.10 a b c d e
  • 6. CPPH501 – PAPER A. (2019 S1) 6 QUESTION 3 [21] 3.1 What is an escape character? Give an example. [2] 3.2 Propose an appropriate prototype of a function that will return the higher of any two numbers passed as argument to the function [4] 3.3. Write C++ statements for the following: [3] 𝑝𝑝 = �𝑎𝑎2 + 𝑏𝑏2
  • 7. CPPH501 – PAPER A. (2019 S1) 7 3.4. Write C++ statements for the following: [3] 𝑠𝑠𝑠𝑠𝑠𝑠 = 𝑎𝑎(𝑟𝑟𝑛𝑛 − 1) 𝑟𝑟 − 1 3.5 Explain in your own words, the term ‘modularity’ [3]
  • 8. CPPH501 – PAPER A. (2019 S1) 8 3.6 Study the following code and rewrite the program using a “for” loop [6] Write your answer in the space provided below int number = 1; do { cout << number << endl; number++; } while (number <= 10);
  • 9. CPPH501 – PAPER A. (2019 S1) 9 QUESTION 4 [16] Create a program that displays a series of the first 10 Fibonacci numbers (1, 1, 2, 3, 5, 8, 13, 21, 34, and 55). Notice that, beginning with the third number in the series, each Fibonacci number is the sum of the prior two numbers. In other words, 2 is the sum of 1 plus 1, 3 is the sum of 1 plus 2, 5 is the sum of 2 plus 3, and so on. Write two versions of the code: one using the for statement and the other using the while statement. Enter the C++ instructions into a source file named Question5.cpp. Add appropriate comments and any additional instructions required to execute your program. Note: the Fibonacci numbers should appear twice on the screen. Refer to figure 4.1 for sample output. Figure 4.1 QUESTION 5 [6] Write a C++ for loop that will produce the output in figure 5.1. Include appropriate comments and any additional instructions required to execute your program. Figure 5.1 I C:Usersraphirits.TUTD~sktopSickT~st2D~bugSickT~st2.~x~ i s playing t e the FIRST 10 i onacci umbers us ing [for s tatement] i s playing the the FIRST 10 Fibonacci umbers us ing [while s t a tement] any key to continue . . . _ Squat'e 4 16 36 64 100 any key Cube 8 64 216 512 1000 to continue V
  • 10. CPPH501 – PAPER A. (2019 S1) 10 Question 6 [23] Create a program for the sales manager at Computer Haven, a small business that offers motivational seminars to local companies. Table 6-1 shows the charge for attending a seminar. Notice that the charge per person depends on the number of people the company registers. For example, the cost for four registrants is R5 761.32; the cost for two registrants is R4 321.0. The program should allow the sales manager to enter the number of registrants for as many companies as needed. When the sales manager has finished entering the data, the program should calculate and display the total number of people registered, the total charge for those registrants, and the average charge per registrant. For example, if one company registers four people and another company registers two people, the total number of people registered is six, the total charge is R10 082.32, and the average charge per registrant is R1680.38. Number of people a company registers Charge per person (R) 1 – 3 2160.50 4 – 9 1440.33 10 or more 1296.30 Table 6.1 Include necessary statements to compile and run your program. See figure 6.1 for sample output.
  • 11. CPPH501 – PAPER A. (2019 S1) 11 Figure 5-1 QUESTION 7 [10] Write, compile and run a C++ program to input the following values into an array named velocity: 10.95, 16.32, 12.14, 8.33, 45.20, 36.45, 7.89, 12.35 and 11.54. After your data has been entered have your program display the values. first coApany (negative nuAber to stop the prograA): 4 registered by the next coApany (negative nuAber to stop the prograA): 2 registered by the next coApany (negative nuAber to stop the prograA): -5 otal nuAber of registrants: 6 otal charge for all registrants: R10082.32 uerage charge per registrant: R1680.39 registered by the next COApany (negative registered by the next COApany (negative registered by the next COApany (negative registered by the next COApany (negative registered by the next COApany (negative registered by the next COApany (negative registered by the next COApany (negative registered by the next COApany (negative registered by the next COApany (negative otal nuAber of registrants: 50 otal charge for all registrants: R?561?.39 verage charge per registrant: R1512.35 nm11ber to stop the pl"Ogl"aA): 8 nm11ber to stop the pl"Ogl"aA): 3 nm11ber to stop the pl"Ogl"aA): 1 nm11ber to stop the pl"Ogl"aA): 3 nm11ber to stop the pl"Ogl"aA): 4 nm11ber to stop the pl"Ogl"aA): ? nm11ber to stop the pl"Ogl"aA): 10 nm11ber to stop the pl"Ogl"aA): 9 nm11ber to stop the pl"Ogl"aA): -1 y
  • 12. CPPH501 – PAPER A. (2019 S1) 12 INSTRUCTIONS TO STUDENTS - All codes must be copied into a single file (MS word file, or any other format recommended by the lecturer) - The file name must match your student number - Student name and student number must be written at the top of the submitted file!! - All practical work must be submitted on myTutor - Make sure the lecturer or invigilator has collected your project before leaving the venue!