First read in an input value for variable numVals. The. Read numVals integer from input and output each integer on a newline after the string “position-“
Ex input 2, 80, 45,
output position-80
position-45
#include <iostream>
musing namespace std;
int main() {
Int numVals;
for(int i=0;I<numVals;I++)
#include <iostream>
using namespace std;
int main() {
int numVals;
cin >> numVals;
for (int i = 0; i < numVals; i++) {
int val;
cin >> val;
cout << "position-" << val << endl;
}
//another solution, if needed to enter all numbers and only then output
/*
int numVals;
cin >> numVals;
int vals[numVals];
for (int i = 0; i < numVals; i++)
cin >> vals[i];
for (int i = 0; i < numVals; i++)
cout << "position-" << vals[i] << endl;
*/
}
Comments
Leave a comment