TP5

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

TP05

1. Write a function that take 2 real numbers as parameters and return the greatest.

2. Write a function that can calculate the summation of 3 integers.

3. Write a function that can calculate the summation from 1 to n positive number
where n is passed as parameter.

4. Write a function that test if a character exists in a string or not. A user is required to
input a string then a character.

5. Write an algorithm and complete code which can perform 5 operations such as:
1) compute factorial of an input number,
2) do summation of numbers from 1 to an input number,
3) find the square root of an input number,
4) check if an input number is a prime number,
5) exit the program.
Each operation should be created as a function. The program displays a menu having
those 5 operations to a user. When the user selects an operation, the function for
performing that operation should be executed and ask a user will be asked for some
required inputs.
The program displays the result for the selected operation and continues displaying
the menu again and again until the user selects ‘exit the program’.

Hint: Create 4 functions for the first four operations. In the main program, a function
is called when user input a corresponding operation.

You might also like