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

C Oops

The document introduces a C++ program that implements a Circle class with private member variables for radius. It includes member functions to calculate the area and circumference of the circle. The main function prompts the user for the radius and displays the calculated circumference and area based on the input.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views2 pages

C Oops

The document introduces a C++ program that implements a Circle class with private member variables for radius. It includes member functions to calculate the area and circumference of the circle. The main function prompts the user for the radius and displays the calculated circumference and area based on the input.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Welcome to C++ OOPs world !

Here we will solve some problems on oops concept .

1. Write a C++ program to implement a class called


Circle that has private member variables for radius.
Include member functions to calculate the circle's
area and circumference.

Sol.
#include <iostream>
using namespace std;

class circle{
private:
float radius;
public:
void setradius(float t){
radius=t;
}
float circumference(){
float c;
c= 2*3.14*radius;
return c;
}
float area(){
float a;
a=3.14*radius*radius;
return a;
}
};

int main() {
// Write C++ code here
circle c;
float r,circum,area;
cout<<"Enter the radius"<<" "<<endl;
cin>>r;
[Link](r);
circum=[Link]();
area=[Link]();
cout<<"Your circumference of circle is :"<<circum<<"
"<<endl;
cout<<"Your area of circle is :"<<area<<" "<<endl;

return 0;
}

Output:
Enter the radius
4
Your circumference of circle is :25.12
Your area of circle is :50.24

[Link]

continue above link

You might also like