Académique Documents
Professionnel Documents
Culture Documents
Enrollment #: _________________________________
Class: _________________________________
Objective
Go through Lab 1 of the manual, attempt the given programs and verify their outputs. Once you
are done, perform the following tasks.
Task 1 :
1. Write the prototype of a function named fnct() which accepts an int by value, a float by
reference and returns a char.
2. Using three variables a,b & c, call the function: double power(double, double);
a. void function();
b. void function(void);
c. void function(int);
d. function(int);
e. int function();
4. A function needs to compute the average as well as the sum of three integers passed to it
and return the answers in the main(). Suggest the prototype for this function.
Task 2 :
1. int cube(int);
int main()
{
for(int i=0;i<10;i+=3)
cout << cube(i) << endl;
return 0;
}
int cube(int a)
{
return a*a*a;
}
Output:
2. int larger(int,int);
int main()
{
int x=10,y=5;
int m = larger(x,y);
cout<<m<<endl;
return 0;
}
Output:
3. void decrement(int);
int main()
{
int x=10;
cout<< x <<endl;
decrement(x);
cout<< x <<endl;
return 0;
}
void decrement(int x)
{
x--;
cout<< x <<endl;
x--;
Output:
Exercise 1
Exercise 2
Write a program with a function volume() which accepts three sides of a cube
and returns its volume. Provide a default value of 1 for all the three sides of a
cube. Call this function with zero, one, two and three arguments and display the
volume returned in the main().
Do Exercises 1 and 2 and get them checked by your instructor. If you are unable to complete
the tasks in the lab session, deposit this journal alongwith your programs (printed or
handwritten) before the start of the next lab session.
+++++++++++++++++++++++++