To input numbers into an array and output after.
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
const int Length = 10;
float arr[Length], x;
int i, cnt;
cout << "Enter up to 10 numbers \n"
<< "(Quit with a letter):" << endl;
for( i = 0; i < Length && cin >> x; ++i)
arr[i] = x;
cnt = i;
cout << "The given numbers:\n" << endl;
for( i = 0; i < cnt; ++i)
cout << setw(10) << arr[i];
cout << endl;
return 0;
}
Related examples in the same category