C ++ Inline Function Area of Circle
Task: Write down a C++ program to use an inline function named Area(). This function will calculate and return the area of a circle. The radius of the circle is a parameter to the Area() function.
How this program with Inline Function Works?
First of all we will write a main function in C++. The user will provide an input called radius of the circle. The main function will pass the radius to the inline function as parameter.
The function Area() will accept the parameter and calculate the area of the circle by using the following formula:
Formula for calcuating Area of Circle
area of circle = 3.1415 x radius2
That is : area = 3.1415 x radius x radius
The C++ expression for the above formula is as follows:
area = 3.1415 * radius * radius;
Because we use * for multiplication in C++ programming language.
The source code for Inline function program in C++
Out put from another sample run
Enter Radius of circle=1.5673
Area of circle using Inline Function is : 7.71687
Process exited after 10.9 seconds with return value 0
Press any key to continue . . .
8,810 total views, 10 views today