Answer to Question #301741 in C++ for Program Training

Question #301741

First, read in an input value for variable numInput. Then, read numInput integers from input and output each integer on a newline after the string "input = ". 

Ex: If the input is 2 30 40, the output is:

input = 30
input = 40
1
Expert's answer
2022-02-23T12:18:43-0500
#include <iostream>
using namespace std;

int main() {
    int numInput;

    cin >> numInput;

    int* input = new int[numInput];
    for (int i=0; i<numInput; i++) {
        cin >> input[i];
    }

    for (int i=0; i<numInput; i++) {
        cout << "input = " << input[i] << endl;
    }
    delete [] input;

    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog