Number printing problem

how to make a program in which a user is prompted to input four numbers like 1234 and then print those four numbers one by one on screen using only one variable..??
For example:1
2
3
4

in ascending order...

I've done that with two methods but i am not sure wether the methods were correct..So any reply would be helpful...thank you!
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>
#include <array>
#include <algorithm>

using namespace std;

int main()
{
	array<int, 4> a;
	for (int i = 0; i < 4; i++) cin >> a[i];
	sort(a.begin(), a.end());
	for (int i = 0; i < 4; i++) cout << a[i] << '\n';
}
Topic archived. No new replies allowed.