Загрузил milena.t210

репорт

реклама
CYPRUS INTERNATIONAL UNIVERSITY
FACULTY OF ENGINEERING
DEPARTMENT OF COMPUTER ENGINEERING
CPE112 – LAB 5
Exercise1: Write a complete C++ program that gets two numbers from user and calculate the result by
selecting the operation from the menu provided below:
Menu
1)Summation
2)Subtraction
3)Multiplication
4)Division
5)Exit
Please choose operation: 1
Please enter two numbers: 2
5
The result of 5 + 2 = 7
Do you want to continue(press y to continue or any key to exit)?
Note: If the user selects 5, then application will be closed.
(Hint: use do while loop structure!)
Exercise2: Write a complete C++ program that gets two numbers (x and y) from user. Calculate and
display the original result, rounds the original result to the smallest value not less than the original
result and, rounds the original result to the largest integer not grater than the original result by
using the formulas below. (Hint: use predefined (math) library functions!)
𝑥
𝑦
𝑒 𝑥 𝑙𝑛( )
𝑦
a) y = 2𝑥 + √𝑦
𝑥 𝑦 +𝑐𝑜𝑠(
c) y =
𝑥
𝑦
2
b) y = 𝑙𝑜𝑔(2𝑦)
4𝑥
)
𝑦
2𝑥
𝑥 |
𝑐𝑜𝑠( )
2𝑦
(𝑡𝑎𝑛( )) +|
Exercise3: Write a complete C++ program that calculates the factorial of the given number by the user.
(Hint: use user defined functions that are provided!)
Function1: void factorial(int x);
Function2: int factorial(int y);
Exercise4: Write a complete C++ program that gets the radius and height, and calculates the volume of
cylinder. (Hint: use user defined function that is provided!)
Function: double calculate_volume(double radius, height);
Formula to calculate the volume: V =𝜋𝑟 2 ℎ
Скачать