Hello CplusPlus forum.
Im making a simple program using for-loop with this output:
but my code doesnt seem to work.
Here's my code:
for ( int x = 1234; x; x /= 10 ) std::cout << x << std::endl;
EDIT: Or if you are using any positive number ( not only 1234) then you can write
unsigned int y = 0;
std::cout << "Enter a positive number: ";
std::cin >> y;
for ( unsigned int x = y; x; x /= 10 ) std::cout << x << std::endl;
Last edited on
Thanks for your replys Vlad and Rapunzel
I've got it. and added some extras :D