Created
July 12, 2017 04:33
-
-
Save pattrickrice/5add50f8d294fec9b18dee8786e15740 to your computer and use it in GitHub Desktop.
CS 161 Project 3a
This file contains 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<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