Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //NickG
- //Max-Min
- #include <iostream>
- #include "valid.hpp"
- #include "clear.hpp"
- using namespace std;
- int main() {
- int least, most;
- char response;
- clear();
- do {
- least=most=0; //Reset least and most
- for (int counter=0, check=0, input; counter<=check; counter++) {
- if (counter==0) {
- cout << "How many numbers would you like to compare:";
- cin >> check;
- intvalid(&check);
- cin.ignore(255,'\n');
- clear();
- }
- else {
- cout << "Input a number:";
- cin >> input;
- intvalid(&input);
- cin.ignore(255,'\n');
- if (counter==1)
- {least=most=input;}
- else {
- if (input>most)
- {most=input;}
- if (input<least)
- {least=input;}
- }
- clear();
- }
- }
- cout << "The lowest number is " << least << " and it is ";
- if (least%2 == 0)
- {cout << "even." <<endl;}
- else
- {cout << "odd." <<endl;}
- cout << "The greateast number is " << most << " and it is ";
- if (most%2 == 0)
- {cout << "even." <<endl;}
- else
- {cout << "odd." <<endl;}
- do { //Response Loop
- cout << "Run Again? (y/n)";
- cin >> response;
- } while ((response!='y')&&(response!='Y')&&(response!='n')&&(response!='N')); //Wait for valid input
- clear();
- } while ((response=='y')||(response=='Y'));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement