Skip to content

Instantly share code, notes, and snippets.

@m-primo
Created April 25, 2020 14:43
Show Gist options
  • Save m-primo/6a1f7bced22e35869663b0a147313705 to your computer and use it in GitHub Desktop.
Save m-primo/6a1f7bced22e35869663b0a147313705 to your computer and use it in GitHub Desktop.
find the largest value in c++
#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