Answer to Question #69476 in C++ for James
Question #69476
C++ program using arrays that asks the user to type 10 integers and writes the smallest value.
Expert's answer
Asnwer:
#include <iostream>
using namespace std;
int main(void)
{
int array[10];
for(int i=0; i<10; i++)
{
cout << "Enter integer number: ";
cin >> array[i];
}
int smallestValue = array[0];
for(int i=1; i<10; i++)
{
if (smallestValue > array[i])
smallestValue = array[i];
}
cout << endl << "Smallest value: " << smallestValue << endl;
return 0;
}
#include <iostream>
using namespace std;
int main(void)
{
int array[10];
for(int i=0; i<10; i++)
{
cout << "Enter integer number: ";
cin >> array[i];
}
int smallestValue = array[0];
for(int i=1; i<10; i++)
{
if (smallestValue > array[i])
smallestValue = array[i];
}
cout << endl << "Smallest value: " << smallestValue << endl;
return 0;
}
Need a fast expert's response?
Submit orderand get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Comments
Leave a comment