Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

= assignment operator

int num=30;

+= operator
a=10,b=30;
a+=b; :: we add right operands to the left operands
a+=b; :: a=a+b;

a=10+30-> 40
b-=a; b=b-a;
b=30-40 = -10
a=40, b=30;
a -> operands
b -> operands

#include<stdio.h>
int main()
{
int a=10,b=30;
a+=b; // a=a+b; a=10+30 :: a=40
printf("Value of a and b :: %d %d",a,b);
}

-=
1. c=8,d=20
2. d-=c; // d=d-c; d=20-8 :: 12
3. d=12, c=8;

c=-d; c=-20;
c-=d; c=c-d;

#include<stdio.h>
int main()
{
int c=8,d=20;
d-=c;
printf("Value of c and d :: %d %d",c,d);
}
*=
1. m=3,n=10
2. n*=m; // n=n*m:: n=10*3 :: 30
3. m*=m; // m=m*m :: 3*3 :: 9
4. m=9,n=30

#include<stdio.h>
int main()
{
int m=3,n=10;
n*=m;
m*=m;
printf("Value of m and n %d %d",m,n);
}

/=
1. m=3,n=20;
2. n/=m; // n=n/m; n=20/3 :: 6
3. m*=n; // m=m*n; m=18;

#include<stdio.h>
int main()
{
int m=3,n=20;
n/=m;
m*=n;
printf("Value of m and n :: %d %d",m,n);
}

%=
1. m=3,n=20;
2. n%=m; // n=n%m; n=20%3 :: n=2
3. n*=m; // n=2*3; 6

v+=t;; v=v+t;
v=+t;;
#include<stdio.h>
int main()
{
int m=3,n=20;
n%=m; // n=n%m; // 20%3 -> 2
n*=m;
printf("Value of m and n :: %d %d",m,n);
}

You might also like