Programming Example
C Program to Calculate Area of Right angle Triangle
In this program we will calculate Area of Right angle Triangle
#include"stdio.h"
int main() {
int base, height;
float area;
printf("\nEnter the base of Right Angle Triangle : \n");
scanf("%d", &base);
printf("\nEnter the height of Right Angle Triangle : \n");
scanf("%d", &height);
area = 0.5 * base * height;
printf("\nArea of Right Angle Triangle : %f \n", area);
return (0);
}
Enter the base of Right Angle Triangle :
5
Enter the height of Right Angle Triangle :
8
Area of Right Angle Triangle : 20.000000
Press any key to continue . . .
First read the algorithm, then study the program code line by line. After that, compare the code with the output and finally go through the explanation. This approach helps learners understand both the logic and the implementation properly.
After understanding this example, try to rewrite the same program without looking at the code. Then change some values or logic and run it again. This helps improve confidence and keeps learners engaged on the page for longer.