#include<stdio.h>
#include<conio.h>
int main()
{
int figure;
float side,base,length,breadth,height,area,radius;
printf(".............\n");
printf("1 Circle\n");
printf("2 Rectangle\n");
printf("3 Triangle\n");
printf("4 Square\n");
printf(".............\n");
printf("\Enter the Code of the Figure:\n");
scanf("%d",&figure);
switch(figure)
{
case 1:
printf("Enter the radius:\n");
scanf("%f",&radius);
area=3.1416*radius*radius;
printf("\nArea of the Circle = %f\n",area);
break;
case 2:
printf("Enter the length and breadth:\n");
scanf("%f",&length,&breadth);
area=length*breadth;
printf("\nArea of the Rectangle = %f\n",area);
break;
case 3:
printf("Enter the base and height:\n");
scanf("%f%f",&base,&height);
area=0.5*base*height;
printf("\nArea of the Triangle = %f\n",area);
break;
case 4:
printf("Enter the side of the square:\n");
scanf("%f",&side);
area=side*side;
printf("\nArea of the Square = %f\n",area);
break;
default:
printf("No such figure exists!\n");
break;
}
getch();
return 0;
}
Friday, 27 April 2012
Program in C for computing the Area of different Geometrical Figures
Labels:
Basic C Programs,
Basic Programs in C,
C,
C Program for Calculating Area of Circle,
C Program for Calculating Area of Triangle,
C Program for Calculating Areas of Geometrical Figures,
C Programs for B.Tech CSE,
C Programs for Engineers,
Data Structures and Algorithms in C,
Implementations in C,
Important C Programs for Interviews,
Important Programs in C++,
Interesting Programs in C Language,
Programming for Engineers
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment