Pseudocode and Algorithm to find Maximum of 3 numbers

(473 Views)


In this post, we will be learning how to find the Maximum or Largest or Greatest number among 3 numbers given as input.

Pseudocode to find Largest of 3 numbers :

READ three numbers and store it in n1,n2,n3 IF n1>n2 IF n1>n3 WRITE "n1 is Maximum" ELSE WRITE "n3 is Maximum" ENDIF ELSE IF n2>n3 WRITE "n2 is Maximum" ELSE WRITE "n3 is Maximum" ENDIF

In the above pseudocode, we first take three inputs from user and store them in n1, n2 and n3. Then check whether n1 is greater than n2. If n1 is greater than n2, then check again whether n1 is also greater than n3. If yes, Print "n1 is max", else Print "n3 is max". But if first condition i.e n1>n2 is false, we need to again check whether n2 is greater than n3, If yes then we print "n2 is Maximum" else we Print "n3 is maximum"


Algorithm to find Greatest of 3 numbers :

Step 1: Start Step 2: Declare variables n1, n2, n3 Step 3: If n1 is greater than n2, If n1 is greater than n3, Display "n1 is Maximum" Else Display "n3 is Maximum" Else If n2 is greater than n3, Display "n2 is Maximum" Else Display "n3 is Maximum" Step 4: Stop

Solution Worked 6 UpvotesUpvote

        

Solution Didn't Worked 1 DownvotesDownvote



Comments



Search