Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(TCO 6) Write a function to have a user enter some number of integers into an ar

ID: 1797327 • Letter: #

Question

(TCO 6) Write a function to have a user enter some number of integers into an array. The integer values must be between -100 and +100 inclusive (+100 and -100 should be accepted as valid inputs). The integer array and the size of the array are passed into the function through parameters. Do not worry about includes. This is only a function, so there is no main routine. The function should fill the array with valid inputs. For invalid input values, inform the user of the error, but do not count that as a valid input.

Explanation / Answer

void insert(int a[], int k)

{

for(int i=0; i<k; i++)

{

cout << "enter integer in rage -100 to 100 " ;

cin >> a[i];

while(!(a[i]>=-100 && a[i]<=100))

{

cout << "enter integer in rage -100 to 100 " ;

cin >> a[i];

}

}

}