GTU PPS Practical-2
Table of content:
Logic :
Logic of this program is very simple as everyone knows the basic mathematics to find area of triangle.
Let us quickly recall the formula of the area of a triangle.
Area of triangle (A) = 0.5 * height * base
You can also check this : find the area of triangle by heron's formula
In this program, we have to take the height and base of a triangle from the user and we display the area of the triangle.
Let's look at the algorithm.
Algorithm :
- START
- Input height and base of triangle.
- Compute area = 0.5*height*base.
- print area.
- STOP
Code :
#include<stdio.h> int main() { float area, height, base; printf("Enter the base of triangle(in cm):"); scanf("%f", &base); printf("Enter the height of triangle(in cm):"); scanf("%f", &height); area= 0.5 * height *base ; printf("The area of given triangle is %.2f cm^2", area); return 0; }
Output :
Here you can see output screen of the code.You can get this type of output if you write above code.
Also check
Find the area of triangle by heron's formulaTHANK YOU
0 Comments
Donot make a spam in comment box.