Don't worry, I'm not going to tell my teacher that I made this.
Code:
#include <iostream.h>
#include <conio.h>
int main()
{
unsigned long long sayi;
cout << "Input number: ";
if (!(cin >> sayi) || (sayi > 99999))
return !!(cout << "Bad number" << endl);
cout << sayi;
size_t div, plus;
if (plus = div = sayi / 10000)
cout << " = " << div << "*10000";
if (div = (sayi = sayi % 10000) / 1000)
cout << (plus ? " + " : " = ") << div << "*1000";
if (plus |= div, div = (sayi = sayi % 1000) / 100)
cout << (plus ? " + " : " = ") << div << "*100";
if (plus |= div, div = (sayi = sayi % 100) / 10)
cout << (plus ? " + " : " = ") << div << "*10";
if (plus |= div, div = sayi % 10)
cout << (plus ? " + " : " = ") << div << "*1";
getch();
}
I've made something like this, but as you can see it only works up to 5 digits. I know it can be done this way (and I know this isn't the right way) using : and ? operators but I don't know how to use them. Can you guys help me turn this program to 19-digit supporting program without exceeding the limits my teacher wanted? Thanks.