C Program to Calculate Area and Perimeter of a Triangle
#include<stdio.h>
void main()
{
float base, height;
int a, b, c;
float area, perimeter;
printf("Enter base and height of triangle: ");
scanf("%f %f",&base,&height);
area = 0.5 * base * height;
printf("Enter three sides of triangle: ");
scanf("%d %d %d",&a,&b,&c);
perimeter = a + b + c;
printf("Area of triangle = %f\n",area);
printf("Perimeter of triangle = %f",perimeter);
}
Comments
Post a Comment