i' using following logic testing whether triangle isosceles, equilateral, scalene or right angled.
if (side1 == side2 || side2 == side3 || side1 == side3) printf("isosceles triangle."); else if (side1 == side2 && side2 == side3 && side3 == side1) printf("equilateral triangle");
i output sides 3 3 3 isosceles not equilateral when interchange logic write logic of equilateral first equilateral. can't understand what's happening?
you shouldn't use else
in case.
code:
if (condition) code else if (condition2) code2
checks if condition true. if executes code. if condition false, condition2 checked , code2 executed.
Comments
Post a Comment