0
Can anybody pls explain this logic and working of program. Mainly why we are using semicolon after the first for loop.
3 Respostas
+ 4
For 1234 i become 1000
Then 1234%1000=234
Then 234%100=34
.
.
So it's printing
1234
234
34
4
Jayakrishna🇮🇳 I think you just reversed it.. just check your answer
+ 1
Its printing pattern like ex:
1234
123
12
1
So there first loop find 10 power of number of digits.. for 1234 =>I=1000
So then 2nd loop prints 1234 and makes n=1234%100=>123
This is repeated till n>0;
Semicolon at the end of loop means there is no body or statements in for the loop...
Remove warning..
why long int main()?
use int main(){..}
instead of %ld (used for long int ) , use %d (used for int type)
Hope it helps..
edit:
Akhil.OR
yes. it actually a bit reverse print, instead n/I, its working n%i so it's printing reminder instead of quotient .
so output is
1234
234
34
4
remaining all works same.
+ 1
Arun Ruban SJ
yes. I focused on question instead of output. Iam not noticed that. it actually a bit reverse print, instead n/I, its working n%i so it's printing reminder instead of quotient .
so output is
1234
234
34
4
Remaining almost same works..,👍👍