DEV Community

selmon haftom
selmon haftom

Posted on

Pre-increment Operator: C Program

In pre-increment, first the value of the variable is incremented after that the assignment or other operations are carried

#include <stdio.h>

int main()
{
int a = 11 ,b;
b = ++a;  

    printf("b = %d\n\n", b);  
    printf("a = %d\n", a);  

    return 0;  
}
Enter fullscreen mode Exit fullscreen mode

Output
b = 12
a = 12

Here first the value of a increments and then is assigned to variable b. So both a and b value will be 11.

Top comments (0)