C++ Tutorial Questions – Idoko’s Part
Answer Questions 1 to 10 as assignment and submit on the 15th of
September to Joy after the exam.
1. State three properties each, of (i) variable (ii) function
2. Explain the following using valid C++ statements;
i. Pass by Value
ii. Pass by Reference
3. Explain the concept of function overloading using valid C++ codes.
4. Write a C++ function that returns the square of any value sent to its parameters from
the main function.
5. State the syntax for defining a function
6. State the difference between searching and sorting
7. Given the following properties of Triangle Area Finder app;
SN FUNCTION RETURN OPERATION
NAME TYPE
1 semiPerimeter double Computes and return semi perimeter using
𝑎+𝑏+𝑐
𝑝=
2
2 trangleArea double Computes and return the area of a triangle using
𝑡𝑎 = √𝑝(𝑝 − 𝑎)(𝑝 − 𝑏)(𝑝 − 𝑐)
As a student developer in a software company, you are requested to write an application
program that properly exchange data between the two (2) functions listed above to
calculate the area of a triangle. The application must contain the main function where the
3 sides of the triangle (a,b,c) will be inputted via the command prompt, and the area of the
triangle (ta) displayed on the command prompt.
8.
SNO PROPERTY METHOD NAME RETURN FORMULA
TYPE
1 Distance(D) distance double
1
D = ut +2 𝑎𝑡 2
2 Square(X) int int X= n * n
Write an application program that properly exchange data between the two (2)
functions listed above to calculate distance from the second equation of linearly
accelerated motion and square of any number. The application must contain the main
function where the parameters u, a, t, and n will be read from the keyboard and the
distance (D) as well as the square(X) displayed on the screen.
9.
SNO PROPERTY METHOD RETURN FORMULA
NAME TYPE
𝑛
1 AP Sum(sn) sum double sn = [2𝑎 + (𝑛 − 1)𝑑]
2
2 Force(f) force double f= m * a
Write an application program that properly exchange data between the two (2)
functions listed above to calculate the sum of an AP and force on a body. The
application must contain the main function where the parameters a, n, d, and m will
be read from the keyboard and the AP Sum (sn) as well as the Force (f) displayed on
the screen.
10.
SNO PROPERTY METHOD NAME RETURN FORMULA
TYPE
1 CelsToFahr(cf) celsToFahr double
9.0
cf = 5 ∗ 𝐶𝑒𝑙𝑠𝑖𝑢𝑠 +
32
2 cube(c) int int c= n*n*n
Write an application program that properly exchange data between the two (2)
functions listed above to calculate Fahrenheit temperature given the Celsius
temperature value and cube of any number. The application must contain the main
function where the parameters celsius and n will be read from the keyboard and the
Fahrenheit (cf) as well as the cube(c) displayed on the screen.