What is the output for ?= Operator? - C Operator

C examples for Operator:Compound Operator

Description

What is the output for ?= Operator?

iRunningTotal = iRunningTotal - iNewTotal; 

can be rewritten to.

iRunningTotal -= iNewTotal; 

Demonstrating the -= assignment further is the following program.

Demo Code

#include <stdio.h> 
int main()/*w w  w. j a va  2s.co  m*/
{ 
   int x = 1; 
   int y = 2; 
   x = y * x + 1;   //arithmetic operations performed before assignment 
   printf("\nThe value of x is: %d\n", x); 
   x = 1; 
   y = 2; 
   x -= y * x + 1;   //arithmetic operations performed before assignment 
   printf("The value of x is: %d\n", x); 
}

Result


Related Tutorials