So here is what I plan to hand in to my professor, he requires comments so many of those comments are "duh" comments but I felt i had to include them.
Code:#include <stdio.h>
#include <conio.h>
#include <math.h>
int main ()
{
int side1, side2, side3;
double semiperimeter;
double area;
do{
printf("Please enter three sides to a triangle. \n");
scanf("%d %d %d", &side1, &side2, &side3);
semiperimeter = (double)(side1 + side2 + side3) / 2; /* Using (side1 + side2 + side3)/2.0 can be subsituted for the word double */
area = sqrt(semiperimeter * (semiperimeter - side1) * (semiperimeter - side2) * (semiperimeter - side3));
if (side1 + side2 > side3 && side2 + side3 > side1 && side1 + side3 > side2) /* Using Heron's law to determine whether inputed numbers are a triangle */
{
if ((side1 == side2) && (side2 == side3))
printf("\nThis triangles sides are %d,%d,%d and is an equalateral triangles.\nIts area is %.05f.\n\n", side1, side2, side3, area);
else if ((side1 == side2) || (side2 == side3) || (side1 == side3))
printf("\nThis triangles sides are %d,%d,%d and is an Isosceles triangle.\nIts area is %.05f.\n\n", side1, side2, side3, area); /* If heron's law is passed, each statement is checked to give correct triangle */
else
printf("\nThis triangles sides are %d,%d,%d and is a Scalene triangle.\nIts area is %.05f.\n\n", side1, side2, side3, area);
}
else
printf("\n%d,%d,%d are not valid sides to a triangle. This program will now terminate.\n", side1, side2, side3); /* Will end the program once user inputs an incorrect combination of numbers. */
}while ((side1 + side2 >side3) && (side2 + side3 >side1) && (side1 + side3 > side2)); /* If it passes Heron's law it will keep looping, if not program terminates. */
getch(); /* Allows user to press a character before program exits. */
return 0;
}