Question: Differentiate between formal parameter and actual parameter.
Answer:
Sometimes the calling function supplies some values to the called function. These are known as parameters. The variables which supply the values to a calling function called actual parameters. The variable which receive the value from called statement are termed formal parameters.
Consider the following example that evaluates the area of a circle. Here radius is called actual parameter and r is called formal parameter.
/* This program illustrates actual and
formal parameter of function */
#include <stdio.h>
void print_area(float);
int main()
{
float radius;
printf("Enter radius of circle: ");
scanf("%f", &radius);
print_area(radius);
return 0;
}
void print_area(float r)
{
float area;
area = 3.14 * r * r;
printf("The area of circle is %f\n", area);
}