Page 84 - Modular_V1.1_Flipbook
P. 84
3. In call by value, changes made to the parameters inside the function have no effect on the
…………………… .
4. The …………………… of a function contains the functionality of the function within curly braces.
5. …………………… simplify the code by breaking it into smaller units.
D. Short answer type questions.
1. What is a function?
2. What is a function prototype?
3. What is the use of void in a function definition?
4. What is the use of the return statement in a function?
5. What are global variables?
E. Long answer type questions.
1. What is the difference between declaring a function and defining a function? Give an example.
2. What is the difference between local and global variables?
3. What is the difference between formal parameters and actual arguments?
4. Write a function to display your name five times.
F. Find the error in the following codes:
1. int div(int a, int b)
{
a = a * b;
b = b / 2;
}
2. sum(int i, j) 3. void disp() {
{ cout>>”program”;
return (I / j) }
}
Critical Thinking
In the lab
Write a program using functions to:
determine whether the year is leap or not.
check whether the input number is even or odd.
find the sum of even numbers between 1 and 50.
find the product of first 5 numbers.
Teacher's Corner
1. Discuss different types of functions provided by C++ with the students.
2. Do a walk-through of all the topics covered in this chapter.
82 Touchpad MODULAR (Version 1.1)-X

