Hello, I'm currently working on a program that reads in 3 numbers then tells you what triangle it is or if its invalid
I'm pretty much nearly finished except I need help on 2 things
Code:
#include <stdio.h>
int main()
{
int side1 = 0;
int side2 = 0;
int side3 = 0;
while(side1 != 'q')
{
printf("Please input the length of the Triangle Sides\n");
printf("Side A: ");
scanf("%d", &side1);
printf("Side B: ");
scanf("%d", &side2);
printf("Side C: ");
scanf("%d", &side3);
if (side1>side2){
if (side2==side3)
printf("Your triangle is Isoceles.\n");
}
if (side1 == side2){
if (side1 == side3)
printf("Your triangle is Equilateral.\n");
}
if (side1 != side2){
if (side2 != side3)
printf("Your triangle is Scalene.\n");
}
else
printf("Not a valid Triangle!\n");
}
return(0);
}
1) Whenever I input three equal numbers the message comes up "Your Triangle is Equilateral" but then on the next line it says "Not a valid Triangle".
This doesn't happen for the others though...
2) Is possible to make it the program loop forever until the user inputs 'q' at any time? At the moment it only quits when the user inputs q for side1
Thanks for any advice!