What is the output? increments x after/before the assignment - C Operator

C examples for Operator:Increment Decrement Operator

Description

What is the output? increments x after/before the assignment

Demo Code

#include <stdio.h> 
int main(){ //ww  w  . j av  a 2 s  . co  m
   int x = 0; 
   int y = 1; 

   x = y++ * 2;   //increments x after the assignment 
   printf("\nThe value of x is: %d\n", x);  
   x = 0; 
   y = 1; 
   x = ++y * 2;   //increments x before the assignment 
   printf("The value of x is: %d\n", x); 
}

Result


Related Tutorials