Checking how increment operation works in c

Viewed 34
#include <stdio.h>

int main(void) {
    int a,b,c,d;
    a=5;
    scanf("%d",&d);
    b=(++a)+(++a);
    printf("changed declared value = %d operated value = %d\n",a,b);
    c=(++d)+(++d);
    printf("changed input value= %d operated value= %d ",d,c);
    return 0;
}

variable a is assigned value 5 and d is given value 5 from user. Then same increment operation is performed but output is different. Can someone explain why this is happening. Tried both cases on same compiler.

output image

0 Answers
Related