Number and Use Double Data Type Also For Functions Having Return Type
Number and Use Double Data Type Also For Functions Having Return Type
UNIVERSITY OF GONDAR
FACULTY OF TECHNOLOGY
DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING
INTRODUCTION TO COMPUTER PROGRAMMING LAB EXERCISE PART 3 ON
FUNCTIONS prepared by Wondimu B.
e. Exponent of x.
2. Write a c++ program with a function named area for the following four conditions:
Note: the number of parameters should be two and both parameter should accept double precision
number and use double data type also for functions having return type.
3. Write a c++ program with a function named area that has two parameters. Both parameter
should accept an integer number. The body of the function should just display the area of
1
Prepared by Wondimu B.
.
UNIVERSITY OF GONDAR
FACULTY OF TECHNOLOGY
DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING
INTRODUCTION TO COMPUTER PROGRAMMING LAB EXERCISE PART 3 ON
FUNCTIONS prepared by Wondimu B.
4. Write a c++ program with a function named add that has two parameters. Both parameter
should accept an integer number. The body of the function should just display the sum of
5. Write a c++ program with a function named check that has three parameters. The first
parameter should accept an integer number, the second parameter a floating point number
and the third parameter a double-precision number. The body of the function should just
display the sum of values of data passed to the function when it is called.
6. Write a program to accept a number from the keyword and print the square and cube of
that number. Use two functions one for calculating and returning the square of the number
and another function for calculating and returning the cube of the number.
7. Using a function call write a c++ program that implements the following problems.
𝑥2 𝑥3 𝑥𝑛
a. 𝑥 + + +⋯+
2! 3! 𝑛!
2
Prepared by Wondimu B.
.
UNIVERSITY OF GONDAR
FACULTY OF TECHNOLOGY
DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING
INTRODUCTION TO COMPUTER PROGRAMMING LAB EXERCISE PART 3 ON
FUNCTIONS prepared by Wondimu B.
Assume except for division all of the function accepts integer parameter and returns also integer
number. For division take double data type for two parameters and returns also a double precision
number. Add one another function named menu that displays the menu at the first when the output
3
I/i…..∫1 𝑓(𝑥)𝑑𝑥 𝑤ℎ𝑒𝑟𝑒 𝑓(𝑥) = 𝑥 3 + 4𝑥 − 7
𝑑
D/d….. 𝑓(𝑥) 𝑎𝑡 𝑥 = 𝑎 𝑤ℎ𝑒𝑟𝑒 𝑓(𝑥) = 𝑥 4 + 4𝑥 2 − 8𝑥 + 7
𝑑𝑥
3
Prepared by Wondimu B.