C Operators

Assignment Operator

	#include 
	void main()	
	{		
		int sum;		
		sum = 500 + 15;		
		printf("The sum of 500 and 15 is %d\n", sum);
		getch();
	}
	
Example 
		x + = 1 is same as x = x + 1 

     The commonly used shorthand assignment operators are as follows 

	Simple form		       Shorthand form
	a = a + 1			  a += 1
	a = a - 1			  a -= 1
	a = a*(n+1)		          a *= (n+1)
	a = a/(n+1)		          a /= (n+1)
	a = a % b			  a %= b 		

Assignment Operator is used to assign the result of an expression to a variable.
Example: x = a + b
Here the value of a + b is evaluated and stored to the variable x. In addition, C has a set of shorthand assignment operators of the form. v op = exp;
where v is a variable, exp is an expression and op is a C binary arithmetic operator.
The operator op= is known as shorthand assignment operator.


Make Comments..!!


Oops!! No posts from user.

Download Android App