codescracker


c++

C++ Program to Calculate Area and Circumference of Circle



« Previous Program Next Program »


Calculate Area and Circumference of Circle in C++

To calculate area and circumference of any circle in C++ Programming, you have to ask to the user to enter the radius of circle, place the radius in a variable say r and make two variable, one for area and other for circumference, and place 3.14*r*r in area and 2*3.14*r in circumference, then display the result on the screen as shown here in the following program.

C++ Programming Code to Calculate Area and Circumference of Circle

Following program ask to the user to enter the radius of a circle, to calculate and display the area and perimeter of the circle:

C++ Programming Example Code:
/* C++ Program - Calculate Area and Circumference of Circle */
		
#include<iostream.h>
#include<conio.h>
void main()
{
	clrscr();
	float r, area, circum;
	cout<<"Enter the radius of the circle :";
	cin>>r;
	area=3.14*r*r;
	circum=2*3.14*r;
	cout<<"Area of the circle = "<<area<<"\nCircumference of the circle = "<<circum<<"\n";
	getch();
}

When the above C++ program is compile and executed, it will produce the following result:

C++ program area circumference

Same Program in Other Language

You may like the same program in other programming languages:


« Previous Program Next Program »



Tools
Calculator

Quick Links
Signup - Login - Give Online Test