The area of triangle using C language | C language prectical | pps solution GTU

 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 
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 :

  1. START
  2. Input height and base of triangle.
  3. Compute area = 0.5*height*base.
  4. print area.
  5. 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.

c-program-to-find-area-of-triangle



Also check
Find the area of triangle by heron's formula

THANK YOU 

Post a Comment

0 Comments