Skip to content

Instantly share code, notes, and snippets.

@pattrickrice
Created July 12, 2017 04:33
Show Gist options
  • Save pattrickrice/5add50f8d294fec9b18dee8786e15740 to your computer and use it in GitHub Desktop.
Save pattrickrice/5add50f8d294fec9b18dee8786e15740 to your computer and use it in GitHub Desktop.
CS 161 Project 3a
#include<iostream>
/****************************************************************
* Name: Patrick Rice
* Date: 7/8/2017
* Description: This program asks the user how many integers they
* would like to evaluate, and then prompts the user said number
* of integers. The evaluates each input and finds the min and
* max of the range.
***************************************************************/
using std::cout;
using std::cin;
using std::endl;
int main() {
int numberOfIntegers,
firstInt,
nextInt,
min,
max,
intCounter;
cout << "How many integers would you like to enter?" << endl;
cin >> numberOfIntegers;
cout << "Please enter " << numberOfIntegers << " integers." << endl;
cin >> firstInt;
min = firstInt;
max = firstInt;
intCounter = 1;
while(intCounter < numberOfIntegers){
cin >> nextInt;
if(nextInt < min){
min = nextInt;
}else if(nextInt > max){
max = nextInt;
}
intCounter++;
}
cout << "min: " << min << endl;
cout << "max: " << max << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment