I am trying to write a c program which you input 3 sides of a triangle and it tells you if it is a valid triangle of not and what kind of triangle it is, it compiles and runs without errors but the only problem is that is always tells me the triangle is isoscles.
Code:#include <stdio.h> int main() { int a, b, c; printf("Please enter side a "); scanf("%d%*c", &a); printf("Please enter side b :"); scanf("%d%*c", &b); printf("Please enter side c :"); scanf("%d%*c", &c); if(a + b > c) { printf("This is a valid "); if(a == b == c) printf("Equalateral Triangle"); else if(a == b != c) printf("Isoscles Triangle"); else if(a == c != b) printf("Isoscles Triangle"); else if(a != b == c) printf("Isoscles Triangle"); else if (a != b != c) printf("Scalene Triangle"); } else printf("Triangle is not valid"); return(0); }



LinkBack URL
About LinkBacks


