jituTechnology

jituTechnology

>2.5 Write a program to represent a Circle to calculate area and perimeter

>

/*Write a program to represent a Circle. Include member functions to perform the following task:

a.     Calculate area of the circle
b.     Calculate perimeter of the circle
Programmed by:
Name: Jitendra Kr Yadav
Roll: 10116 (NCIT-ELX)
Date: 23 july 2011*/
#include <iostream.h>
#include <conio.h>
class Circle
{
private:
float r;
public:
void assign(float a)
{
r=a;
}
void area()
{
cout<<“Area of the circle is: “<<3.14*r*r<<endl;
}
void peri()
{
cout<<“The perimeter of circle is: “<<2*3.14*r;
}
};
int main()
{
Circle c;
float a;
cout<<“Enter the radius of a circle:”;
cin>>a;
c.assign(a);
c.area();
c.peri();
getch();
return(0);     
}
Output sample:
Enter the radius of a circle: 2.24
Area of the circle is: 15.7553
The perimeter of circle is: 14.0672

No comments yet.

Add a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.



Connect with Me

GPO 8973 NPC 541; Kathmandu Nepal
Phone: +977 9851236800

Calendar

April 2024
S M T W T F S
 123456
78910111213
14151617181920
21222324252627
282930