GfG QA is closing soon... Please refer PRACTICE or GfG now on wards !!

Why is the solution of given code is 196

#include <stdio.h>
int main(void) {
	
	int i=12;
	int ans=++i*++i;
	printf("%d",ans);
	return 0;
}

 

asked Aug 2, 2016 by Piyush

1 Answer

Because when you write first ++i, it makes i =13 and then you again write ++i then it makes i= 14. So ans = 14*14 = 196. Basically ++i fist update the value of i then it gets processed.
answered Aug 3, 2016 by Jeetash
...