Chapter - 2: C Instructions

If lengths of three sides of a triangle are input through the keyboard, write a program to find the area of the triangle.


H
Sections
6
Exercises

A

B

C

D

E

F

G

H

1

2

3

4

5

6

7

8

9

10

#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
	float a , b , c , s , area;
	
	printf("\nEnter three sides of the triangle : ");
	scanf("%f%f%f", &a, &b, &c);
	
	//Finding area of the triangle by the Heron's Formula
	s = (a+b+c)/2;
	area = sqrt(s*(s-a)*(s-b)*(s-c));
	//sqrt() is a funtion that find the square root.
	
	printf("\nArea : %f", area);
	
	getch();
	return 0;
}

© 2020 Garbage Valuegarbage value logo