Tuesday 21 July 2020

5.11 (Find the Smallest Value) Write an application that finds the smallest of several integers. Assume that the first value read specifies the number of values to input from the user.


#include 
 
using namespace std;
 
int main()
{
  int i, smallest;
  cout << "Enter integers (The first value read\nspecifies the number of values remaining):";
  cin >> i;
  cin >> smallest;
 
  for(int b; i > 1; i-- )
  {
  cin >> b;
    if( b < smallest )
      smallest = b;
   }
  cout << "Smallest integer is " << smallest << endl;
 
   //for pause
   system("PAUSE");
   return 0;
}

No comments:

Post a Comment