I cannot figure out the ending while. It goes to an infinite loop!?
Code:
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
int main(void)
{
int a, b, c, s, area;
char answer;
do {
printf("Input 3 positive integers: \n");
scanf("%d %d %d", &a, &b, &c);
if ((a + b <= c) || (a + c <= b) || (c + b <= a)){
printf("These are not a valid triangle's sides\n %d %d %d\n", a, b, c);
}
else
{
if ((a == b) && (a == c) && (b == c)){
printf("This is an equilateral triangle\n");
}
else if ((a == b) || (a == c) || (b == c)){
printf("This is an isosceles triangle\n");
}
else if ((a != b) || (a != c) || (b != c)){
printf("This is a scalene triangle\n");
}
s = (a + b + c) / 2.0;
area = sqrt(s*(s - a)*(s - b)*(s - c));
printf("The area of triangle is: %d \n", s);
}
printf("If you need to try another integers type y otherwise n : ");
scanf("%d", &answer);
}
while (answer != 'y');
return 0;
}