Reputation: 5
I am faced with a question that goes like this:
Write an algorithm that reads three integers a, b, c
representing the sides of a triangle.
Next, print the type of triangle represented (scalene, equilateral, isosceles).
Assume a valid triangle is represented.
I would like some feedback on the errors that my algorithm may present or what I can do to improve how sequential it is:
step 1) Start
step 2) Declare int a,b,c
step 3) Prompt a,b,c
step 4) Read a,b,c
step 5) If (a<>b and b<>c and c<>a) then
step 6) Print "Scalene Triangle"
step 7) Elseif((a=b and a != c) or (a=c and a!=b) or (b=c and b!=a))
step 8) Print "Isoceles Triangle"
step 9) Elseif ((a=b & b!=c ) or (a=c & c!=b) or (b=c & c!=a)) then
step 10) Print "Equilateral Triangle"
step 11) Endif
step 12) Stop
Upvotes: 0
Views: 11300
Reputation: 56
There are 4 types of Triangles
Consider A , B and C as 3 sides possible triangle then
Upvotes: 1
Reputation: 621
You'll get equilateral triangle as an isoceles triangle too,so change it to:
Upvotes: 0