Question: stion 1 Write function headers for the functions described below: ( i ) The function check has two parameters. The first parameter should be an
stion
Write function headers for the functions described below:
i The function check has two parameters. The first parameter should be an integer number and the
second parameter a floating point number. The function returns no value.
ii The function mult has two floating point numbers as parameters and returns the result of
multiplying them.
iii The function time inputs seconds, minutes and hours and returns them as parameters to its
calling function.
iv The function countChar returns the number of occurrences of a character in a string, both provided as
parameters.
Question
Find the errors in each of the following program segments and explain how the errors can be
corrected:
i int function
cout "Inside function function
DUE DATE May
UNIQUE NUMBER
EXTENSION There is days extension for this assignment
TUTORIAL MATTER Study Guide, Lessons
CONTRIBUTION WEIGHT TO
YEAR MARK
QUESTIONS Practical exercises
INP
endl; int function
cout "Inside function function endl;
ii int sumint x int y
int result;
result x
y;
iii int computeProdint n
if n
return ;
else
n computeProdn ;
iv void aFunctionfloat a
float a;
cout a endl;
v void theProduct
int
a;
int
b;
int
c;
int result;
cout Enter three integers
endl; cin a b c;
result a b c;
cout Result is result
endl; return result;
INP
vi float calculateSquarefloat number
return number number;
Question
Write the functions as described below. You need not submit programs that use these functions.
i Write a function that returns the cube of the integer passed to it For example cube will
return and
cube will return
ii Write a void function that receives four int parameters: the first two by value and the last two by
reference. Name the formal parameters n n sum and diff. The function should calculate the sum of
the two parameters passed by value and then store the result in the first variable passed by reference. It
should calculate the difference between the two parameters passed by value and then store the result in
the second parameter passed by reference. When calculating the difference, subtract the larger value from
the smaller value. Name the function calcSumAndDiff.
iii Write a function void rectangleint w int h to print an open rectangle of asterisks The
parameters w and h are the width and the height of the rectangle, expressed in number of asterisks.
iv Write a function, computePrice that receives two parameters: the first one is a character variable
indicating the size of the pizza S M or L and the second an integer variable indicating the number of
toppings on the pizza. It then computes the cost of the pizza and returns the cost as a floating point
number according to the rules:
Small pizza R R per topping
Medium pizza R R per topping
Large pizza R R per topping
Question
The post office needs a program that reads in postal address data and then displays the data in a
neat format.
Declare four string variables name, addr addr and postalCode.
First, the main function of the program must input the data by means of a function called inputData.
Second, the main function calls the function displayData to display the name and address as follows:
Mr RS Bopape
PO Box
Sandton
Submit the program and the output.
Question
Write a program that calculates the average of a group of test scores, where the lowest score
in the group is dropped. For example: if the user enters the values and the output
will be:
INP
After dropping the lowest test score, the test average
is
This average is calculated by dropping the lowest score which is and dividing the sum of the
remaining four values and which is by
It should use the following functions:
An int function getScore with no parameters, to ask the user for a single test score, validate it and
return the score. The function should be called by the main function once for each of the five scores to be
entered. Do not accept test scores lower than or higher than
An int function findLowest that is passed the five test scores and then finds and returns the lowest
of the five scores passed to it It is called by function calcAverage, to determine which of the five scores
to drop.
A float function calcAverage that is passed the five test scores and then calculates and returns
the average of the four highest scores.
A void function displayOutput that is passed the average score; it then displays the average of the
test scores. Display two digits after the decimal point.
You must submit the four functions you have developed as well as output using
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
