6.1 Built in Function: Lab Manual # 6 Functions
6.1 Built in Function: Lab Manual # 6 Functions
Functions
int main()
{ // tests the sqrt() function: for
(int x=0; x <=9; x++)
cout << "\t" << x << "\t" << sqrt(x) << endl;
}
Code
6.5.1 Code
6.6 Que No 3
Write a code that take numbers from user and displays its cube. The
Code should reads integers and prints their cubes until the user inputs the
sentinel value 0. Each integer read should be passed to the cube()
function by the call cube(n). The value returned by the function should
replaces the expression cube(n) and then should be passed to the output
object cout.
6.6.1 Code
6.7 Que No 4 finding area of rectangle
Write a function that finds the area of the rectangle on providing length and
width. Get Length & width from user in main() Call the function area()
Calculate the length and return the area Display the result in main()
6.7.1 Code
6.10.1Code
6.11 QueNo 8
Develop a program in C++ that has function printTempOpinion() which prints "Cold"
on if the temperature is below 10, "OK" if the temperature is in the range 20 ->
30,"Hot" if the temperature is above 30.
Code
6.13 Que No 9 Swap by using function
Develop a program that swap the two values using function by reference
i.e After swap
a = 22.2 a = 44.4
b = 44.4 b = 22.2
6.13.1 Code