A function can be invoked (accessed or called) by specifying its name, followed by a list of arguments enclosed in parentheses and separated by commas. If function call does not require any arguments, an empty pair of parentheses must follow the name of the function. the function call may be a part of a simple expression (such as an assignment statements) or it may be one of the operands within a more complex expression. The arguments appearing in the function call are referred to as actual arguments. The salient features of function call is given below.
If the function returns a value, the function access can be written as an assignment statement. For example:
area = process (radius);
The function access causes the value returned by the function to be assigned to the variable area.
On the other hand, if the function does not return any thing, the function access can be written as
addition (a, b, c);
This function access indicates that value of a, b and c to be processed internally and the result is displayed in the function itself.
Program – Calculate the area of a circle
#include
#define PI 3.14159
main ()
{
float redius, area;
float process (float redius);
clrscr ();
printf (“Enter the redius”);
scanf (“%f”, &radius);
area = process (radius);
printf (“Area = %f”, area);
getch ();
}
float process (float r)
{
float a;
a = PI *r* r;
return (a);
}
Output:
Run 1
Enter the redius: 3.21
Area = 32. 371258
Run 2
Enter the redius: 1.5
Area = 7. 068577
Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.
We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc