Notification texts go here Contact Us Click here

Using C program to find area of triangle.

Please wait 0 seconds...
Scroll Down and click on Go to Link for destination
Congrats! Link is Generated

 






Program to calculate area of triangle without using Heron's formula .


#include<stdio.h>
int main()
{  float a,b,area;
    printf("Enter base and height of triangle: ");
    scanf("%f%f",&a,&b);
    area=(a*b)/2;
    printf("Area=%.2f",area);
    return 0;
}

 
OUTPUT :

Enter base and height of triangle

Enter base and height of triangle: 4 2 Area=4.00

  Program to calculate the area of triangle using Heron's  formula .


#include<stdio.h>
#include<math.h>
int main()
{ float a,b,c,s,area;
printf("Enter three sides of triangle: ");
scanf("%f%f%f",&a,&b,&c);
s=(a+b+c)/2;
area=sqrt((s*(s-a)*(s-b)*(s-c)));
printf("Area is = %.2f",area);
return 0;
}
 
 

OUTPUT :

Enter three sides of triangle:3 5 7 Area is = 6.50

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.