C++ program to find the area of a circle using user defined function.
program using a user-defined function findArea(). This function takes radius as its argument and returns the area of circle.
C++ program:
Source Code:
// area of circle using function
#include<iostream>
/* iostream provides basic
input and output services for C++ programs */
using namespace std;
float findArea(float);
//user-defined function findArea()
int main()
// Th execution of program start with the main function
{
// Float is the data type
float radius, area;
//Variable Declarations specify the type followed by the name
cout<<"Enter the Radius of Circle: ";
// cout is used to display the same statement in the output.
cin>>radius;
// cin is used to enter the value by the user.
area = findArea(radius);
cout<<"\nArea of Circle = "<<area;
cout<<endl;
return 0;
}
float findArea(float r)
{
return (3.14*r*r);
}
0 Comments