Â
In this, we are going to see how to find Area of Sector using C++ program.
The formula to calculate is,
Area of Sector = (angle / 360) * pi * radius * radiusÂ
The Code given below can be used in Turbo C++ Compiler.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float area, radius, angle, pi=3.142;
cout<<"This program is for Area of Sector\n";
cout<<"Enter the radius and angle in degrees of the Sector\n";
cin>>radius>>angle;
//formula for area of Sector is (angle/360)*pi*radius*radius
area = (angle/360)*pi*radius*radius;
cout<<"The Area of the Sector with radius "<<radius<<" is = "<<area<<" sq units";
getch();
}
The Code given below can be used in g++/gcc Compiler.
#include<iostream>
using namespace std;
int main()
{
float area, radius, angle, pi=3.142;
cout<<"This program is for Area of Sector\n";
cout<<"Enter the radius and angle in degrees of the Sector\n";
cin>>radius>>angle;
//formula for area of Sector is (angle/360)*pi*radius*radius
area = (angle/360)*pi*radius*radius;
cout<<"The Area of the Sector with radius "<<radius<<" is = "<<area<<" sq units";
return 0;
}
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP