Thursday, 12 September 2013

Separate a five digit integer such as 12345 into 1 2 3 4 5, separating each digit with a tab

Separate a five digit integer such as 12345 into 1 2 3 4 5, separating
each digit with a tab

#include<iostream>
using namespace std;
int main()
{
int x;
int a;
int b;
int c;
int d;
int e;
cout << "Please enter a 5 digit integer.";
cin >> x;
a= x%10 ;
b= x%100 %10;
c= x%1000 %10;
d= x%10000 %10;
e= x%100000 %10;
cout << a
<< b
<< c
<< d
<< e;
return 0;
}
This is what I have so far but I can't seem to cout<< each digit all at
once with a tab.I need to add a tab in between each one of the digits.

No comments:

Post a Comment