0% found this document useful (0 votes)
12 views2 pages

Area of Circle by OOP

Class notes

Uploaded by

saadkhan73212
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views2 pages

Area of Circle by OOP

Class notes

Uploaded by

saadkhan73212
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

channel link : h ps://www.youtube.

com/c/ComputerScienceAcademy7
video link : h ps://youtu.be/bmnoPFMmFGg

/*
OOP : Object Oriented Programming

class: class is user defined data type.

*/

/*

Area of circle by OOP technique

Write a program in C++ to find area of circle by uisng OOP technique.

Implement a class circle to find the area of circle.

Write an Object Oreiented Program to read radius of a circle and display


its area.

declara ons of variables


read values
calcula on
display result

*/

#include<iostream.h>
#include<conio.h>

class circle
{
private:
float r, area;

public:
void getdata()
{
cout<<"Enter radius of a circle: ";
cin>>r; //C.r = 1 //B.r = 2

}
void calcula on()
{
area = 3.14 * r * r; //C.area = 3.14 * C.r * C.r
} //B.area = 3.14 * B.r * B.r

void display()
{
cout<<"Area of circle = "<<area<<endl; //C.area
} //B.area
};

void main()
{
clrscr();

circle C,B;

C.getdata();
C.calcula on();
C.display();

getch();
}

You might also like