Find the biggest and smalles of A,B,C by algorithm

[Solved/Closed]
Report
Posts
2
Registration date
Monday November 26, 2012
Status
Member
Last seen
August 19, 2013
-
Posts
2368
Registration date
Sunday September 23, 2012
Status
Member
Last seen
December 13, 2018
-
Hello,

This is my first question ^^ , I just joined the collage but i have a question related to algorithm
its how to write whats the biggest and smallest value in 3 vars A,B,C
did a flowchart for it but cant change it to algoritm to short form :(
for 1 answer its easy
-start
IF A>B & A>C
then A is the biggest
Else IF B>C
then B is the biggest
Else then C is the biggest
Print the biggest
-end

Regards


???? ???? , ?? ?????? ?????

3 replies

Posts
2368
Registration date
Sunday September 23, 2012
Status
Member
Last seen
December 13, 2018
43
Hi YemenSEF,

You can try the below mentioned algorithm:

largest = x
smallest = x

if (y > largest) then largest = y
if (z > largest) then largest = z

if (y < smallest) then smallest = y
if (z < smallest) then smallest = z

If you want to write the same in any programming language do reply.

Please revert for clarification.
1
Thank you

A few words of thanks would be greatly appreciated. Add comment

CCM 2821 users have said thank you to us this month

Posts
2368
Registration date
Sunday September 23, 2012
Status
Member
Last seen
December 13, 2018
43
Hi YemenSEF,

I appreciate your hard work. Yes, your algorithm will give you the right results. Feel free to approach if you need any further help.
1
Thank you

A few words of thanks would be greatly appreciated. Add comment

CCM 2821 users have said thank you to us this month

Posts
2
Registration date
Monday November 26, 2012
Status
Member
Last seen
August 19, 2013

Thanks very much
but i have already tried alot and found a good answer andi hope its right too
I did one like this
-start
-read ,a,b,c
-IF A>B then
A = larg
B = smal
Else
A=smal
B=larg

-IF C>larg then C=larg
-IF C<smal then C=smal
-Print: smal"Is the smallest" , larg "Is the largest"
-end