Pseudocode and Algorithm to find Maximum of 3 numbers


Today, we will be learning how to find the maximum number among 3 numbers



Pseudocode to find Maximum of 3 numbers

READ 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 Maximum 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 5 UpvotesUpvote
        
Solution Didn't Worked 1 DownvotesDownvote


Comments




Search