-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8842b45
commit de0c015
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Deitel ch.05 exercise 5.11 | ||
// Finding the smallest of several integers | ||
#include <iostream> | ||
|
||
using namespace std; | ||
|
||
int main(){ | ||
int num{0}; // the number of integers entered | ||
int numInput; // input integer for each iteration | ||
int smallest{numInput}; // the smallest number | ||
|
||
cout << "enter the number of integers: \n"; | ||
cin >> num; | ||
|
||
for(int i{1}; i <= num; i++){ | ||
cout << "Enter integer: "<< endl; | ||
cin >> numInput; | ||
|
||
if(numInput < smallest){ | ||
smallest = numInput; | ||
} | ||
} | ||
cout << "the smallest number is "<< smallest << endl; | ||
} |