Write the program from the above flowchart to find the large
Write the program from the above flowchart to find the largest of three integers. Ask the user to enter three integers and select and display the largest of the three integers. Run the program for three different sets of integers where the largest integer is the first, second and third number in the set. Example: Enter three integers and I will tell you the largest number: 478 90 12 The largest is 478 Enter three integers and I will tell you the largest number: 278 399 112 The largest is 399 Enter three integers and I will tell you the largest number: 788 900 2012 The largest is 2012 DO NOT USE THE COMPOUND OPERATOR && WHEN DESIGNING YOUR PROGRAM Find using xyz if x =largest y=largest z= largest
Solution
Write the program from the above flowchart.
Flow Chart is not available.
//Using C++
#include<iostream>
using namespace std;
int main()
{
int x, y, z, largest;
cout<<\"\ Enter three integers and I will tell you the largest number: \";
cin>>x>>y>>z;
largest = x; //Assumes the first number is the largest one
if (y > largest) //Compares with the second number
largest = y; //Stores the second number as largest
if (z > largest) //Compares with the third number
largest = z; //Stores the third number as largest
cout<<\"\ The largest is = \"<<largest;
}
Output 1:
Enter three integers and I will tell you the largest number: 478 90 12
The largest is = 478
Output 2:
Enter three integers and I will tell you the largest number: 278 399 112
The largest is = 399
Output 3:
Enter three integers and I will tell you the largest number: 788 900 2012
The largest is = 2012
