1

im writing this program for an intro to c class, I was wondering if anyone knows whats wrong with this code? it says theres an error with the first else, if i take the curly brackets out it says theres a problem with all 3 else's. Thanks.

#include <stdio.h>

int main ()

{
	int sd1, sd2, sd3;
	
	
	printf("Please enter the first length: \n");
	scanf("%d%*c", &sd1);
	
	printf("Please enter the second length: \n");
	scanf("%d%*c", &sd2);
	
	printf("Please enter the third length: \n");
	scanf("%d%*c", &sd3);
	
	
	if (sd1+sd2<sd3||sd2+sd3<sd1||sd1+sd3<sd2);
		printf ("This is not a triangle");
	else
	
	{
		if (sd1==sd2&&sd2==sd3);
			printf ("Equilateral Triangle");
		else
			
			if (sd1==sd2||sd2==sd3||sd1==sd3);
				printf ("Isoselecs Triangle");
			else
				printf ("Scalene Triangle");
	}
	
	return (0);
}
Votes + Comments
Nice - code tags on your first post :)
2
Contributors
3
Replies
5
Views
7 Years
Discussion Span
Last Post by bleutana
0

> if (sd1+sd2<sd3||sd2+sd3<sd1||sd1+sd3<sd2);
Watch the birdie!

i dont understand the semi colon was already there? what do you mean by watch the birdie?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.