0% found this document useful (0 votes)
66 views3 pages

Number and Use Double Data Type Also For Functions Having Return Type

The document contains instructions for several C++ programming exercises involving functions: 1) Write functions that use library functions to calculate mathematical operations like square root, absolute value, trigonometric functions, exponents, and converting between uppercase and lowercase. 2) Write functions for calculating the area of a rectangle with different combinations of arguments and return types. 3) Write a function that displays the area of a rectangle given two integer arguments. 4) Write a function that displays the sum of two integer arguments. 5) Write a function that displays the sum of arguments of different data types. 6) Write functions to calculate and return the square and cube of a number input by the user.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views3 pages

Number and Use Double Data Type Also For Functions Having Return Type

The document contains instructions for several C++ programming exercises involving functions: 1) Write functions that use library functions to calculate mathematical operations like square root, absolute value, trigonometric functions, exponents, and converting between uppercase and lowercase. 2) Write functions for calculating the area of a rectangle with different combinations of arguments and return types. 3) Write a function that displays the area of a rectangle given two integer arguments. 4) Write a function that displays the sum of two integer arguments. 5) Write a function that displays the sum of arguments of different data types. 6) Write functions to calculate and return the square and cube of a number input by the user.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

.

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.

1. Use a library function to calculate:

a. Calculate the square root of any number.

b. Absolute value of any numbers.

c. Absolute value of decimal numbers.

d. Sine, cosine and tan of angle x.

e. Exponent of x.

f. Calculate x the power of y.

g. Returns the lowercase of value of x if x is uppercase.

h. Returns the uppercase of value of x if x is lowercase.

2. Write a c++ program with a function named area for the following four conditions:

a. Without argument and without return type

b. Without argument and with return type

c. With argument and without return type

d. With argument and with return type

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

the rectangle when it is called.

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

values of data passed to the function when it is called.

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! 𝑛!

b. (𝑥 + 𝑦 + 𝑧)1 + (𝑥 + 𝑦 + 𝑧)2 + ⋯ + (𝑥 + 𝑦 + 𝑧)𝑛

𝑥𝑦 2 𝑧 3 𝑥2𝑦3𝑧4 𝑥3𝑦4𝑧5 𝑥 𝑛 𝑦 𝑛+1 𝑧 𝑛+2


c. + + +⋯+ (3𝑛+3)!
6! 9! 12!

𝑥𝑦 2 𝑧 3 𝑤 4 𝑥 2 𝑦 3 𝑧 4 𝑤5 𝑥 𝑛 𝑦 𝑛+1 𝑧 𝑛+2 𝑤 𝑛+3


d. + 10 + + 14 + ⋯ + (4𝑛+6)!
+ 4𝑛 + 6
10! 14!

8. Integrate function call with switch-case for the following problems.

s………sum of two numbers.

d………. difference of two numbers

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.

m………. multiplication of two numbers

d…………quotient of two numbers

r…………. remainder of two numbers

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

page comes to make it the user choice easier.

3
I/i…..∫1 𝑓(𝑥)𝑑𝑥 𝑤ℎ𝑒𝑟𝑒 𝑓(𝑥) = 𝑥 3 + 4𝑥 − 7
𝑑
D/d….. 𝑓(𝑥) 𝑎𝑡 𝑥 = 𝑎 𝑤ℎ𝑒𝑟𝑒 𝑓(𝑥) = 𝑥 4 + 4𝑥 2 − 8𝑥 + 7
𝑑𝑥

S/s……swaps two inputs x and y.

3
Prepared by Wondimu B.

You might also like