0

#include <stdio.h> int main() { int i=3; if(!i) i++; i++; if(i==3) i+=2; i+=2; printf("%d",i); return 0; }

How 6 I think 7?

21st Aug 2020, 9:15 AM
Rohit Ahuja
Rohit Ahuja - avatar
4 Réponses
+ 4
int i=3; Here value of i is 3 in next line if condition will run here (! ) this is not operator so if(!3) it means 0 so condition will be false so first i++ won't be work after that next i++ will run here value will increase and it will be 4 in next line there is if case so if(4==3) which is false so next line will not work then next line i+=2 this will run it means i=i+2 where i was 4 so i=4+2=6 printf("%d",i); And printf will print 6
21st Aug 2020, 9:31 AM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 1
Indentation or the brakets or a little of both. https://code.sololearn.com/c5Ll0nFUSq6V/?ref=app
21st Aug 2020, 9:20 AM
Slick
Slick - avatar
0
Thanx a lot I know the concept but get confused
21st Aug 2020, 12:40 PM
Rohit Ahuja
Rohit Ahuja - avatar