Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 4

Object Oriented Programming with C++ [CE144] Enrolment No.

:23DCS056

CHAROTAR UNIVERSITY OF SCIENCE & TECHNOLOGY

DEVANG PATEL INSTITUTE OF ADVANCE TECHNOLOGY & RESEARCH

Department of Computer Engineering/Computer Science & Engineering/

Information Technology

Subject Name: Object Oriented Programming with C++


Semester: II
Subject Code: CE144
Academic year: 2023-24

Practical List

No. Aim of the Practical

1
Object Oriented Programming with C++ [CE144] Enrolment No.:23DCS056

1. Develop a system to calculate the area of circle.

PROGRAM CODE:
#include <iostream>
#include <cstdio>
#include <math.h>

using namespace std;

class circle{
private:
float radius;
float pi=2*acos(0);
float area;
public:
circle(){
radius=1;}

circle(float r1){
radius=r1;}

circle(const circle& circle1){


radius=circle1.radius;}

~circle(){
}

2
Object Oriented Programming with C++ [CE144] Enrolment No.:23DCS056

void areacalc(){
area=pi*radius*radius;
cout<<"the area of radius "<<radius<<" is "<<area<<endl;

};

int main(){
class circle *c1;
c1= new circle();
c1->areacalc();
int count=1;
class circle *c2;
float radius;
cout<<"enter the radius for parameter constructor";
cin>>radius;
c2= new circle(radius);
count++;
c2->areacalc();
class circle *c3;
count++;
c3= new circle(*c1);
c3->areacalc();
for(int i=0;i<3;i++){
cout<<"one object is deleted"<<endl;
count--;
cout<<"total active objects are "<<count<<endl;

3
Object Oriented Programming with C++ [CE144] Enrolment No.:23DCS056

}
cout<<"23dcs056_vansh_malani"<<endl;

OUTPUT:

CONCLUSION:

This program helped us understand the three types of constructors: parameterised, default
and copy. it also helped us understand constructor overloading in c++ in objective
programming

You might also like