+ 1
Explain how Output comes out to be 6 ?
#include <stdio.h> int main() { int i = 3; if(!i) i++; i++; if (i==3) i += 2; i += 2; printf("%d",i); return 0; }
3 Antworten
+ 2
//read comments....
#include <stdio.h>
int main() {
int i = 3;
if(!i) //this becomes false,
i++; //so it won't execute..
i++;. //this executes so I=4 now
if (i==3) //4==3 false
i += 2; //it won't execute
i += 2; //it executed so I=4+2=6
printf("%d",i); //here it prints 6
return 0;
}
//Is it clear?
edit:
!i=>!3 => false,
generally any number other than 0 is true, so negating it becomes false..
+ 1
Jayakrishna🇮🇳 Thanks for the answer 🙂
It was a Quiz Challenge Question
+ 1
Yes..
You're welcome...