Area of Circle




In this program const command is used for constant value of pi, it is used for constant values which user want to make constant in their programs. Float data type is used to show the results after decimal, unlinke integer (int) data type float gives us the value after decimal point.

 Program which insert Radius and Calculates Area of Circle while Pi is constant


#include<iostream.h>

#include<conio.h>

const float pi=3.1416;

int main()

{
float a,r;

cout<<"Enter the Radius= ";

cin>>r;

a=pi*(r*r);

cout<<"Area of Circle= "<<a;

getch();

return 0;

}

OUTPUT

No comments :

Post a Comment