+ 1
Why does (I==1; I<=3; I++) printf ("hello") print hello four times instead of three times?
8 Respuestas
+ 3
~ swim ~ that seems to obvious if that is what the learner is looking for.
ASIYA SHAIKH make sure that the question you posted is right and let the community know if you have received the answer you are looking for by acknowledging it.
+ 1
~ swim ~ But then it has to be I = 0 for it to print it 4 times, another mistake.
+ 1
~ swim ~
Agreed as well, but she has some searching and sorting algorithms in her code bits which made me think that this should have been simple for her but the question itself seems wrong.
+ 1
It is assumed that I has been declared and is equal to 0 when this first executes. If I is a stack variable though, this can not be guaranteed and can be any value. The code I==1 simply returns 0 (false) because it is not an assignment, but rather a test. A compiler should warn that I==1 has no effect in this case.it’s also missing the for. The line should be:
for (I=1; I<=3; I++) printf ("hello");