The following is an incorrect algorithm aims to output the largest value out of the 3 variables x, y, and z. Correct and rewrite the following alogorithm: integer x integer y integer z integer max x = Get next input y = Get next input z = Get next input if x > y and x > z    max = x else    if y > z       max = z    else       max = y Put max to output

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 30PE
icon
Related questions
Question

The following is an incorrect algorithm aims to output the largest value out of the 3 variables x, y, and z. Correct and rewrite the following alogorithm:

integer x
integer y
integer z
integer max
x = Get next input
y = Get next input
z = Get next input
if x > y and x > z
   max = x
else
   if y > z
      max = z
   else
      max = y
Put max to output

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning