Create a program that will accept 10 numbers between 1 and 20 as input. If the user enters an invalid number re-prompt with an error message for the number. Output the list of numbers in numerical order.
//output: "Enter a number between 1-20: "
cout << "Enter a number between 1-20: ";
//read an input into x
cin >> x;
//if ( x >= 1 AND x <= 20 )
if( x >= 1 && x <= 20)
{
//add x to the number vector
vec.push_back(x);
}
//else
else
{
//output: "Bad input: Try again."
cout << "Bad input: Try again." << endl;
}
sort (number.begin(),number.end()); // sorting
cout <<"\n Print integers in ascending order :"<< endl;
for ( int i=0; i<number.size(); i++)
{
cout <<"\n"<<number.at(i) << endl;
}
system("PAUSE");
return 0;
}
This is the code i have assembled and it gives me the errors: