| spherecraft (7) | |
|
Hello CplusPlus forum. Im making a simple program using for-loop with this output: 1234 123 12 1 but my code doesnt seem to work. any help? Here's my code: #include<iostream.h> int x,y=1234; main() { for(x=0;x<10;x++) cout<<y; cout<<"\n"; return 0; } THANKS! | |
|
|
|
| vlad from moscow (3662) | |||
|
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
| |||
|
Last edited on
|
|||
| rapunzel (11) | |||
Your program should change :
note : if you need any explanation, tell me:) | |||
|
|
|||
| spherecraft (7) | |
|
Thanks for your replys Vlad and Rapunzel I've got it. and added some extras :D | |
|
|
|