Functions Exercises
Functions Exercises
MENU
1. Add
2. Subtract
3. Multiply
4. Divide
5. Modulus
Enter your choice: 1
Enter your two numbers: 12 15
Result: 27
Continue? y
The program also asks the user to decide whether he/she wants to continue the operation. If
he/she input ‘y’, the program will prompt the user to choose the operation gain. Otherwise, the
program will terminate.
The Fibonacci Sequence is the series of numbers: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ...
The next number is found by adding up the two numbers before it:
1
4. Write a function to calculate the area of a triangle with sides a,b and c.
5. Write a C++ program (using function overloaded) to sort 10 integer values, or 10 long
7. Write a program in C to check a given number is even or odd using the function
8. Write a program in C to find the sum of the series 1!/1+2!/2+3!/3+4!/4+5!/5 using the
function.
9. Write a program in C to convert decimal number to binary number using the function.
10. Write a C++function to print a number in reverse for example input: 124567 output: 765421
11. Write a program in C to check whether a number is a prime number or not using the
function.
12. Write a program in C to get the largest element of an array using the function.
13. Write C++ program that implement the power function using recursion function.
14. Write a recursive function to calculate Fibonacci numbers Xn, n=1,1,2,3,5,8 …,1000