In these primitive data Member we use the void AREA::circle(int r) , void AREA::rectangle(int l,int b) function by using these function we can implement Classes with primitive Data Members in C++ programming OOPS

Source code in c++ Programming OOPS

#include<iostream.h>

#include<conio.h>

#define pi 3.14

class AREA

{

int area1,area2;

public:

void circle(int r);

void rectangle(int l,int b);

};

void AREA::circle(int r)

{

area1=pi*r*r;

cout<<"AREA OF THE CIRCLE : "<<area1;

}

void AREA::rectangle(int l,int b)

{

area2=l*b;

cout<<"AREA OF THE RECTANGLE : "<<area2;

}

void main()

{

int r,l,b;

clrscr();

AREA JJ;

cout<<"\nEnter the radius of the circle : ";

cin>>r;

JJ.circle(r);

cout<<"\n\nEnter the length & breadth of the rectangle : ";

cin>>l>>b;

JJ.rectangle(l,b);

getch();

}

OUTPUT c++ programming for oops

Enter the radius of the circle : 7

AREA OF THE CIRCLE : 153

Enter the length & breadth of the rectangle : 15 7

AREA OF THE RECTANGLE : 105

Source code in c++ Programming OOPS

#include<iostream.h>

#include<conio.h>

#define pi 3.14

class AREA

{

int area1,area2;

public:

void circle(int r);

void rectangle(int l,int b);

};

void AREA::circle(int r)

{

area1=pi*r*r;

cout<<"AREA OF THE CIRCLE : "<<area1;

}

void AREA::rectangle(int l,int b)

{

area2=l*b;

cout<<"AREA OF THE RECTANGLE : "<<area2;

}

void main()

{

int r,l,b;

clrscr();

AREA JJ;

cout<<"\nEnter the radius of the circle : ";

cin>>r;

JJ.circle(r);

cout<<"\n\nEnter the length & breadth of the rectangle : ";

cin>>l>>b;

JJ.rectangle(l,b);

getch();

}

OUTPUT c++ programming for oops

Enter the radius of the circle : 7

AREA OF THE CIRCLE : 153

Enter the length & breadth of the rectangle : 15 7

AREA OF THE RECTANGLE : 105

## No comments:

Write comments