Friday, 19 August 2016

Problem Statement :
Calculate the area of the triangle T with given breadth “b” and height “h” with precison of two
digits after decimal point.
Constraints :
1<t<100
b, h are floating point numbers
0.0<b<1000.0
0.0<h<1000.0
Input :
First line specifies the number of test cases t.
Each of the next t lines contains two real numbers denoting b and h respectively.
Output:
Each line contains area of triangle with precison upto two digits after decimal point.
Sample Input :
4
2 3
5 7
1 3
23 56.0
Sample Output :
3.00
17.50
1.50
644.00



Solution:

#include<stdio.h>
int main()
{
 int i,test;
 float b,h;
 scanf("%d",&test);
    for(i=1;i<=test;i++)
    {
        scanf("%f %f",&b,&h);
        float area=0.5*b*h;
        printf("%0.2f\n",area);
    }
}


No comments:

Post a Comment