CALCULATE AREA IN C:-
Here is short method to calculate the area of triangle,rectangle and other more as the following
programming steps.
1.WAP TO CALCULATE THE ARE OF CIRCLE.
#include<stdio.h>
#include<conio.h>
void main()
{
int b,h,r;
float circle_area;
clrscr();
printf("\t\t\tFOR FIND CIRCLE AREA\n\n");
printf("\t\tenter the radius=");
scanf("%d",&r);
circle_area=3.14*r*r;
printf("\n\t\tcircle_area\t=%f\n\n",circle_area);
getch();
}
O/P:-FOR FIND CIRCLE AREA
enter the radius= 2
circle_area= 12.56
2.WAP TO CALCULATE THE AREA OF TRIANGLE.
#include<stdio.h>
#include<conio.h>
void main()
{
int b,h;
float triangle_area;
clrscr();
printf("\n\t\t\tFOR FIND AREA OF TRIANGLE\n");
printf("\n\t\tenter the hight h=");
scanf("%d",&h);
printf("\n\t\tenter the base b=");
scanf("%d",&b);
triangle_area=0.5*b*h;
printf("\n\t\ttriangle_area\t=%f",triangle_area);
getch();
}
O/P:-FOR FIND AREA OF TRIANGLE
enter the hight h= 2
enter the base b= 4
triangle_area= 4.0
3.WAP TO CALCULATE AREA OF RECTANGLE.
#include<stdio.h>
void main()
{
int b,h,area;
clrscr();
printf("\t\tArea of rectangle");
printf("\tenter the hight");
scanf("%d",&b);
printf("\tenter the value of width=");
scanf("%d",&h);
area=b*h;
printf("Area is=%d",area);
getch();
}
O/P:-Area of rectangle
enter the hight= 2
enter the value of width= 4
Area is= 8
Read More:-Click Here
No comments:
Post a Comment