prev


Assigned Values For Variables

5.Area of Triangle (20.6.2009)

/*
Program# 5
date : 10-12-2008
Area of Triangle
*/

#include <stdio.h>
main(){
float b,c,h;
b=5.0;
h=10.0;
c=1.0/2.0*b*h;
printf("Area is : %f\n",c);
}

output:
Area is : 25.00

Things to note:
In the calculation, if 1/2 is used instead of 1.0/2.0 then the ouput will be zero, since int/int will give only integer value.

next
blog comments powered by Disqus