Seperating Digits

This is a code I wrote to seperate digits of a number.

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
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
	int a, b, c, f=0;
	cout << "Enter an integer: ";
	cin >> a;
	for (int i = 0; i < 1; i++)
	{
		f++;
		c = pow(10, f);
		b = a%c;
		if (b == a)
			i++;
		i--;
	}
	cout << "Number of digits is " << f << ".\n";
	for (int i = f - 1; i >= 0; i--)
	{
		c = pow(10, i);
		cout << (a / c) % 10 << "\t";
	}
	cout << endl;
	system("pause");
	return 0;
}
Topic archived. No new replies allowed.