Programming for Problem Solving

GTU Practical 2

2. Write a program to find area of triangle(a=h*b*.5) a = area h = height b = base
#include<stdio.h>  ( this applies in the given code )

#include
int main()
{
float a,h,b;
printf(“\n Enter height :”);
scanf(“%f”,&h);
printf(“\n Enter base :”);
scanf(“%f”,&b);
a=b*h*0.5;
printf(“\n Area of triangle = %f”,a);
return 0;
}

OUTPUT

Enter height :10

Enter base :5

Area of triangle = 25.000000

GTU STUDY