Assignment Operators In C Language
In C program values for the variables are assigned using assignment operators. The most common assignment operator is ‘=’ this operator assign (copy) the right side value to the left side variable.
  Example :
var =5;  //5 is assigned to var
a=c;   //value of c is assigned to a
5=c;   // Error! 5 is a constant.
Operators Symbol Example Explanation
Simple Assignment Operator = Sum=10 10 is assigned to variable sum
Compound Assignment Operators += Sum+=10 This is same as sum=sum+10
-= Sum-=10 This is same as sum=sum-10
*= Sum*=10 This is same as sum=sum*10
/= Sum/=10 This is same as sum=sum/10
%= Sum%=10 This is same as sum=sum%10
  Program : A program to illustrate the use of Assignment Operators.
#include<stdio.h>
#include<conio.h> 
int main()      
{
int total=0,i;
	for (i=0;i<10;i++)    
  {
		Total+=i;
   }
printf(“total=%d”, total);
 }
Output :

Total= 45

We see you’re using an ad blocker.

Our website is made possible by displaying ads to our visitors.

Please help us continue to provide you with free. So please disabling your ad blocker.