Advertisement
Javinator9889

Get the highest number of 'n' numbers

Nov 11th, 2017
397
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. double returnBiggest();
  5.  
  6. int main() {
  7.     double biggest = returnBiggest();
  8.     cout << "The biggest one is:" << biggest << endl;
  9.     return 0;
  10. }
  11.  
  12. double returnBiggest() {
  13.     double aBiggest;
  14.     double cValue;
  15.     cout << "Please, insert first value: ";
  16.     if (!(cin >> aBiggest)) {
  17.         cout << "At least one value is needed" << endl;
  18.         exit(1);
  19.     }
  20.     cout << endl;
  21.     cout << "Please, insert value (insert any other character for finish program): ";
  22.     while (cin >> cValue) {
  23.         if (cValue > aBiggest)
  24.             aBiggest = cValue;
  25.         cout << endl;
  26.         cout << "Please, insert value (insert any other character for finish program): ";
  27.     }
  28.     return aBiggest;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement