(Find the Smallest Integer) Write a program that uses a for statement to find the smallest of several integers. Assume that the first value read specifies the number of values remaining.
What will be an ideal response?
```
// Find the smallest of several integers.
#include
using namespace std;
int main()
{
int number; // number of values
int value; // current value
int smallest; // smallest value so far
cout << "Enter the number of integers to be processed ";
cout << "followed by the integers: " << endl;
cin >> number >> smallest;
// loop (number -1) times
for ( int i = 2; i <= number; i++ )
{
cin >> value; // read in next value
// if current value less than smallest, update smallest
if ( value < smallest )
smallest = value;
} // end for
// display smallest integer
cout << "\nThe smallest integer is: " << smallest << endl;
} // end main
```
You might also like to view...
What are some of the hackers' motivations?
What will be an ideal response?
Commands to create an index are located on the ________ tab
A) REVIEW B) REFERENCES C) HOME D) INSERT
In the acronym HTTPS, the S stands for ________.
Fill in the blank(s) with the appropriate word(s).
OneDrive files are accessed usin
a. File Manager b. Server Explorer c. File Explorer d. Windows Manager