how is the output 12345678910 | Sololearn: Learn to code for FREE!


how is the output 12345678910

int i = 10; while(i--) cout << 10 - i;

1/9/2020 7:15:19 AM

Ariz imam

4 Answers

New Answer


As in your while loop it specifies that while(i--) it means that it will first evaluate th value of 'i' and then decrement it That's why you are getting ths output At first itteration value that is evaluated is 10 and after that it has been decreased to 9 Similarly at last the value to be evaluated is 1 and after that it is decreased to 0


Ariz imam that's because you are printing '10-i' not 'i'


Arsenic ok mate..


why the thread of output is in reverse.. it should be 10987654321