-5
#include <stdio.h>
#include <string.h>

int main()
{
int i=3,y;
y=++i*++i*++i;
    printf("%d",y);
}

The i value is initially getting incremented to 4.Then it is incremented to 5. therefore it is incremented to 6. accordingly result should come 216. but 150 is coming as a result.

1 Answers1

0
  • It will execute like this;
  • First it is considers like this,

    y = (++i * ++i) * ++i // so first i is incremented to 4 and again it will incremented to 5.
    
  • So now first expression will executed like this

    y = (5 * 5) * ++i; 
    y = 25 * ++i;
    
  • Now again i is incremented to 6 and final expression is like this,

    y = 25 * 6;
    y = 150;
    
Sagar Patel
  • 864
  • 1
  • 11
  • 22