Professional Documents
Culture Documents
1- Area: This function calculates and returns the area of a triangle or a circle based on the
number of arguments passed when calling the function.
Hint: Two overloaded versions of the function should be written. The first version
should take two double arguments (base and height), and return the area of triangle as
double. The second version should take one double argument (radius), and return the
area of circle as double.
2- Cylinder: This function calculates and returns the volume of a cylinder. The function
should take two double arguments (radius, height), and return the volume as double. If
the radius and/or height is not passed, the function should consider them 1 and 2
respectively.
Hint: Set a default argument of 1 for the radius, and 2 for the height.
3- Calculator: This function calculates and returns the sum, difference, product, and
quotient of two double numbers.
Hint: Use the concept of “call by reference” to return the four values from the function.
Main Function:
Write a menu driven program in main.cpp that repeatedly displays the above menu to the
user (call printMenu) and prompt the user to enter his/her choice until the Exit choice is
chosen.
Main Menu
----------------
1- Area of triangle.
2- Area of circle.
3- Volume of cylinder.
4- Calculator.
5- Exit.
Extra Exercise
Implement and test the following functions:
sumOfNaturalNum : this function displays the sum of natural
numbers to number N, the function should take one argument N.
(Recursive Implementation)
e.g: if N=3, the displayed value is 6
" قد تعرف كيف تقرأ ولكن االهم ما الذي تخطط لقراءته, تخطيط%02 مهارة و%02 "النجاح
Spring 2019