Instructions:Write a program that reads three numbers and stores them into variables double x,y, z; Then the code finds double m the minimum of the three numbers and prints its value
#include <iostream>
using namespace std;
int main() {
double x , y, z, m;
cout << " Enter the value of x."<<endl;
cin >> x;
cout << " Enter the value of y."<<endl;
cin >> y;
cout << " Enter the value of z."<<endl;
cin >> z;
if ( x > y )
m = y;
else
m = x;
if ( x > z )
m = z;
else
m = x;
if ( y > z )
m = z;
else
m = y;
cout << "The minimum of the three numbers is " << m << "."<<endl;
return 0;
}
Is this right?
I typed in the numbers 1 for x , 2 for y , 3 for z and i got 2 as the minimum.
Isnt the minimum 1? Do i do something wrong?