Question: Hi, there. Im trying to create a C script that takes user input of 3 verticies to calculate the area of a triangle by using

Hi, there. Im trying to create a C script that takes user input of 3 verticies to calculate the area of a triangle by using Heron' Formula.

Heron's Formula is

S=(A+B+C)/2

Area = sqrt(S(S-A)(S-B)(S-C))

This is the script I have so far. I can't get it to caluclate S correctly nor my area. Any tweaks?

#include #include int main(void){

int verticie_1; int verticie_2; int verticie_3; int find_s; int area; int area_formula;

float s = (verticie_1+verticie_2+verticie_3) /2; find_s = s; float area_s = find_s*((find_s - verticie_1)*(find_s - verticie_2)*(find_s - verticie_3)); area = area_s; float heron_area = sqrt(area_s); area_formula = heron_area;

printf("Enter verticie A: "); scanf("%d",&verticie_1);

printf("Enter verticie B: "); scanf("%d",&verticie_2);

printf("Enter verticie C: "); scanf("%d",&verticie_3);

printf("Your triangle has verticies %d,%d,%d ",verticie_1,verticie_2,verticie_3);

printf("Therefore, S is equal to %d ",find_s);

printf("With the given verticies %d,%d,%d, the area of the triangle is %d ",verticie_1,verticie_2,verticie_3,area_formula);

getchar(); return 0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!