Function in C



How To Calculate Area Of the Circle Using Function in C


Write a function called circleArea() that take the radius of a circle 
as an argument and calculate and return the area. In the main program 
read the radius value from the user, call circleArea() and display the result.

Example

Input
Enter Radius of the Circle: 10
Output
Area of the Circle:314.159


Here in this program we will define more than one user-defined functions in a single program.
Declare functions to find  area of circle

First assign a meaningful name to  the  function. Say function to calculate   area is circleArea() .
The  function uses one input i.e. radius of circle to calculate output. Hence the  function must 
accept a parameter of double or int type.
Finally, all The function returns either double or int as output.
Hence, return type of the function must be either double or int.
Output

No comments:

Post a Comment

MVC Architecture