C++ First, read in an input value for variable numIn. Then, read numIn 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 3 50 -100 90, the output is: 50.-100.90
C++
First, read in an input value for variable numIn. Then, read numIn 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 3 50 -100 90, the output is:
50.-100.90
#include <iostream>
using namespace std;
int main() {
int numIn;
int value;
cin >> numIn;
cout << value;
for (int i = 1; i < numIn; i++) {
cin >> value;
cout << value <<"." << value;
}
cout << endl;
return 0;
}
The provided code takes an integer input 'numIn' from the user and then takes 'numIn' i.e. number of integer inputs. It then prints the input integers separated by dots, except for the last one which is followed by a newline.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images