write a C++ program that repeatedly prompts a user to input a positive integer value. At any point, if the user enters 0 or a negative integer value, then the program should print the minimum of all of the positive integer values entered by the user, and then terminate execution.For example, if a user enters the values 4 13 8 11 2 66 5 0, then the program should report that the smallest of the positive values entered is 2.
Excuse me, I am new for stackoverflow. Here is the code I wrote so far. However, it keeps printing the last 0 or negative number I inserted, not the minimum number. Thank You!
`# include <iostream>`
`using namespace std;`
`int main(){`
`int x, y;`
`cout<<"enter number";`
`cin>>x;`
`while(x!=0){`
`cout<<"enter another number";`
`cin>>y;`
`if (y<x)`
`x=y;`
`if (y>x)`
`x=x;`
`if (y<=0)`
`x=x;`
`}`
`cout<<"the minimum number is"<<x;`
return 0;
}
Excuse me, I am new for stackoverflow. Here is the code I wrote so far. However, it keeps printing the last 0 or negative number I inserted, not the minimum number. Thank You!
`# include <iostream>`
`using namespace std;`
`int main(){`
`int x, y;`
`cout<<"enter number";`
`cin>>x;`
`while(x!=0){`
`cout<<"enter another number";`
`cin>>y;`
`if (y<x)`
`x=y;`
`if (y>x)`
`x=x;`
`if (y<=0)`
`x=x;`
`}`
`cout<<"the minimum number is"<<x;`
return 0;
}