How do I seperate integers?
Hi,
I'm doing this little program at the moment where I have to imput a 5-digit integer, seperate the number into its individual digits and prints the digits seperated from one another by three spaces each.
It gives me a hint that I should use the division and modulus operators.
Iv'e started like this, but really am clueless how to tackle this, can anyone give me a few tips and/or pointers
thanks for any help
Code:
int main(int argc, char* argv[])
{
int number;
cout << "Enter a five digit integer: ";
cin >> number;
number = number / 10;
cout << number;
number = number / 100;
cout << number;
number = number / 1000;
cout << number;
number = number / 10000;
cout << number;
getch();
return 0;
}