C QUESTIONS 1 Define the terms actual parameter and formal p
C++ QUESTIONS!!!
1) Define the terms actual parameter and formal parameter. What requirement must they satisfy?
2) Describe the purpose of the return statement in a function. What requirement must it satisfy?
3) What is the purpose of a function prototype? Where should it appear in a program?
4) What is the purpose of a default parameter? How is it defined?
5) What is the disadvantage of using a global variable?
6) What is the purpose of the scope resolution operator?
Solution
(1)
Formal parameter:
An identifiere which is used in the function definition
to get value that is passed into the function .
For example,
int sum(int a, int b)
{
return (a+b);
}
where a and b are formal parameters.
Actual parameters:
The actual value that is passed to the function.
For example, calling sum method from main function
int res=sum(10,20);
where 10 and 20 are actual parameters.
Note: The return type , function name and order of data types
must be same for the calling function and called function
must satisfy.
(2)
return statement:
A function statement contains the data type otherthan
void then the function must return a value.
for example,
float getArea()
{
return PI*radius*radius;
}
The calling function gets the result from the function
that contains the return statement.
(3)
function prototype:
The function prototype is defined in the header section
of the program that indicates that the function is defined inside
the program.
It should be appear before function defintion .
Most likely in header section of the program.
#include<iostream>
using namesapce std;
//function prototype declaration part
int main()
{
}
(4)
Default parameter:
A function is defined with argument list then the default
values are set to the actual values of the function
if the user ommitted to set the values of the function.
//function prototype
void sum (int a=0, int b=0);
Even user forgot to set values for a and b values,
the program takes default values to the calling function.
(5)
gloabal variable:
A gloabal variable is declared outside of the main funciton
of the program and it is accessble anywhere in the program.
So that user can modify or alter the value of the gloabal variable.
The disadvantage of the global variable is that the value
is not consistant and it is not secured by access specifiers or any scope of method.

