Created
April 25, 2020 14:43
-
-
Save m-primo/6a1f7bced22e35869663b0a147313705 to your computer and use it in GitHub Desktop.
find the largest value in c++
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "stdafx.h" | |
#include <iostream> | |
using namespace std; | |
int main() { | |
int itemValue; | |
int largestSoFar; | |
int minValue; | |
minValue = -200000000; | |
largestSoFar = minValue; | |
cout << "Finding the largest value..." << endl; | |
do { | |
cout << "Enter an integer (or " << minValue << " to stop): "; | |
cin >> itemValue; | |
if(itemValue > largestSoFar){ | |
largestSoFar = itemValue; | |
} | |
} while(itemValue != minValue); | |
cout << "The largest value: " << largestSoFar << endl; | |
system("pause"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment