Solution to First, read in an input value for variable numVals. Then, read numVals integers from input … - Sikademy
Author Image

Archangel Macsika

First, read in an input value for variable numVals. Then, read numVals integers from input and output each on the same line with the character ", " between each value. End with a newline. Note: ", " should not be at the beginning or end of the output. Ex: If the input is 4 -60 -35 -15 -45, the output is: -60, -35, -15, -45

The Answer to the Question
is below this banner.

Can't find a solution anywhere?

NEED A FAST ANSWER TO ANY QUESTION OR ASSIGNMENT?

Get the Answers Now!

You will get a detailed answer to your question or assignment in the shortest time possible.

Here's the Solution to this Question


#include <iostream> #include <string> using namespace std; int main() { int numVal; cout << "Input: "; cin>> numVal; string* numbers=new string[numVal]; for (int i = 0; i < numVal; i++) { cin >> numbers[i]; } for (int i = 0; i < numVal; i++) { if(i== numVal-1) cout<<numbers[i]; else cout << numbers[i] << ","; } delete[] numbers; }

Related Answers

Was this answer helpful?

Join our Community to stay in the know

Get updates for similar and other helpful Answers

Question ID: mtid-3-stid-44-sqid-1093-qpid-89