Area of circle and circumference

.
Hii from Team(S.A.O.P)

Today's topic is C++ program for finding area of circle and circumference of circle. we gonna make a program called "Circle.cpp"(C++ Program)....although we need little bite knowledge of Maths(formulas of finding area of circle and circumference).

Lets begin with basic knowledge of maths(circle).

June117.blogspot.com

The distance around a 
circle is called its circumference.
 The distance across a circle through its center is called
 its diameter. We use the Greek letter  (pronounced Pi)
 to represent the ratio of the circumference of a circle to the
 diameter.
 = 3.14
i have just wrote Important points here..

Formula of Area of circle:

Area = *Radius²
how we gonna write this in our program
for  here i have created one variable called PI and assign a value 3.14(The value of 
PI = 3.14
Area = PI*r*r;

 Formula of circumference:

there is two way to find circumference
i)Ci = 2**r
ii)Ci=*d
note: "d" is our diameter
now lets implement this in our program.

Program

#include"iostream"
#include<conio.h>
using namespace std;//If your using turbo c then remove this statement
class Circle {
public:
int rad;
    float PI = 3.14, area, ci;
void area_of_circle()
{
cout<<"Enter radius of circle: "<<endl;
    cin>>rad;
   area = PI * rad * rad;
  cout<<"Area of circle : "<< area<<endl;
}
void circumference()
{
ci = 2 * PI * rad;
  cout<<"Circumference : "<< ci<<endl;
}
};
int main(int argc, char**argv)
{
cout<<"June117.blogspot.com"<<endl;
Circle c1;
c1.area_of_circle();
c1.circumference();
getch();
return 0;

Summery: 

In above program i have created a class called Circle.in class i have developed two function one for finding area of circle and second for circumference.
 I define radius as integer and PI( = 3.14),area and ci(circumference) as Float.
If your Using Turbo C/C++  for coding this program then don't forget to put "getch()" and you don't need to write "Using namespace std;"

Facebook link: https://www.facebook.com/TeamSAOP/

if you have any query then you can ask me in comment
Thanks You
This Blog is presented by (S.A.O.P) and 127.0.0.1is heaven

Comments