about separating digits

Hey guys , first of all I wanted to ask is it ok , if sometimes when you don't know how to solve a problem " you tried but you couldn't solve it "
, you look in google and get hints or something and then try to solve it after that ? Because I sometime do this but I really feel upset after that , it's like lying to myself :(

anyways When I was reviewing the book I saw a problem that says : put a number and then separate it , for example : 4197 it should print 4 1 9 7
I used an old program that I had which reverse the digits and then modified it to print it to solve this problem , yeah I solved it , but the thing is the chapter was before arrays , so I think they wanted me to do it without using arrays, is there a better solution ?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include<iostream>
using namespace std;
int main(){

	int x = 4652;
	int rev = 0;
	int array[4];

	for (int i = 0; x != 0; i++){

		rev = x % 10;
		x = x / 10;

		array[i] = { rev };

	}
	for (int j = 3; j >= 0; j--){
		cout << array[j] << " ";
	}






	cin.get();
	cin.get();
	return 0;
}
closed account (Dy7SLyTq)
its perfectly fine to google it. the point of programming is to challenge your self, but it is perfectly fine to google something to learn a new skill. for example, i could spend a couple of hours pouring over winapi pages to find the functions i can use to make my program a background progress or i can google it real quick, which saves me time and allows me to focus on skills i want to work on. as to your solution, i could show you a way with out arrays, but how advanced am i allowed to get?
Topic archived. No new replies allowed.