Answer to Question #325104 in C++ for nickname

Question #325104

Let's start with an easy one. Create an array that stores 4 integers. Ask the user to enter any 4 numbers, one by one. Finally, output those numbers separated by three spaces.

 

Output:


This program will ask you to enter 4 numbers. It will then confirm your entries.

Enter a number:  [user types: 1]


Enter a number:  [user types: 2]


Enter a number:  [user types: 3]


Enter a number:  [user types: 4]


Your numbers: 1  2  3  4


1
Expert's answer
2022-04-10T12:36:19-0400
#include<iostream>

using namespace std;

int main()
{
	int arr[4];
	for (int i = 0; i < 4; i++)
	{
		cout << "Please, enter a value " << i + 1 << ": ";
		cin >> arr[i];
	}
	for (int i = 0; i < 4; i++)
	{
		cout << arr[i]<<" ";
	}
}

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
APPROVED BY CLIENTS