You don't need the y,Y,n or N variables, but I left them in so you could polish it up.
This is working code.
Code:
/*Included Files*/
#include <stdio.h>
#include <math.h>
int main(void)
{
float side1, side2, side3, s, area;
char loop, y,Y, n,N, ch;
//with while loops you frequently need to "prime the pump" (assign the
//value of your control variable).
loop = 'y';
while (loop == 'y' || loop == 'Y')
{
/*Input*/
printf ("Enter the value for side 1:" );
scanf ("%f", &side1);
printf ("Enter the value for side 2:" );
scanf ("%f", &side2);
printf ("Enter the value for side 3:" );
scanf ("%f, %c", &side3);
/*Error Checking*/
if (side1&&side2&&side3 !=0)
{
if ((side1+side2<=side3) || (side1+side3<=side2) || (side2+side3<=side1))
printf ( "The triangle is invalid.\n");
else if ((side1==side2) && (side2==side3))
{
printf ( "The triangle is an equilateral triangle.\n");
s =(side1+side2+side3)/2;
area=sqrt(s*(s-side1)*(s-side2)*(s-side3));
printf ("The area of the triangle is %6.2f\n", area);
}
else if ((side1==side2) || (side1==side3) || (side2==side3))
{
printf ( "The triangle is isosceles.\n");
s =(side1+side2+side3)/2;
area=sqrt(s*(s-side1)*(s-side2)*(s-side3));
printf ("The area of the triangle is %6.2f\n", area);
}
else if ((side1!=side2) && (side2!=side3) && (side1!=side3))
{
printf ( "The triangle is scalene. \n");
s =(side1+side2+side3)/2;
area=sqrt(s*(s-side1)*(s-side2)*(s-side3));
printf ("The area of the triangle is %6.2f\n", area);
}
}
else printf ( "The triangle is invalid.\n");
printf ( "Would you like to try another triangle? Enter Y/N:");
//ch = getchar();
scanf (" %c", &loop);
}
ch++; //just stops a stupid warning on my compiler
return 0;
}
/*
When you use scanf(), it may leave a newline char '\n', in the keyboard
buffer. A following scanf() for a number, will skip that '\n' char, and act
like you want.
A following scanf() for a char or a string, will not. It will see the '\n'
as the only char that you want to enter, and "skip" over the scan(),
goofing up your program.
There are two common solutions:
1) Use a getchar() to "pull" the '\n' char, off the keyboard buffer, or
2) Put a space into the scanf() function, telling it to ignore the first
char it runs across.
An example of #1:
ch = getchar();
scanf ("%c", &loop);
An example of #2:
scanf (" %c", &loop); //note the space before the %c
*/