I want to take a number ( exemple 14 ) than extract the 1 in X and 4 in y. Then I want to add x+y who will give me 5. Why this code dont work ?

Code:
int lucky(int x)
{
	if (x > 10)
	{
		while(x < 10)
		{
				y= x % 10;
				x= x / 10;
		}
	}
	else
	{
		luckyt = x + y;
		cout<<luckyt<<endl;
	}
	luckyt = x + y;
	cout<<luckyt<<endl;
	return 0;
}