Advertisement
kalin729

Min and Max While!+0 With Functions

Jun 17th, 2018
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. int n,nmax=-9999999, nmin=9999999;
  5.  
  6. void getMin(int n){
  7.     if(n<nmin && n!=0){nmin=n;}
  8. }
  9.  
  10. void getMax(int n){
  11.     if(n>nmax && n!=0){nmax=n;}
  12. }
  13.  
  14. void enterNum(){
  15.     cin >> n;
  16.     getMin(n);
  17.     getMax(n);
  18.     while(n!=0){
  19.         enterNum();
  20.     }
  21. }
  22.  
  23. int main(){
  24.  
  25. enterNum();
  26. cout << "Min: " << nmin << endl;
  27. cout << "Max: " << nmax << endl;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement