TOP CATEGORIES

×

How to use the assignment operators in c?

V

Vishal Verma

Assignment operators in C

In C programming an assignment operator is used to assign the value of an expression into a variable. In C programming = is the most frequently used assignment operator. Generally assignment operator = is used line variable=expression.

for example-

int a=5, b=9, c=11, res;

res=a+b+c // use of assignment operator

Explanation - In the above example res is a variable and a+b+c is an expression.

Note - It is not compulsory that is should always have a big expression, it can also have a value, other variables for example 

res=a or res=20 or res=b+c etc.

Types of Assignment operators in C

In C programming assignment operator is only one type but it has many extend mode, below I'm going to explain all extended assignment operators one by one.

  • +=
  • -=
  • *=
  • /=
  • %=

If m and n are variable then...

Use of +=

m+=n means m=m+n

Use of -=

m-=n means m=m-n

Use of *=

m*=n means m=m*n

Use of /=

m/=n means m=m/n

Use of %=

m%=n means m=m%n

0 votes

Your Answer

Email: advertise@gdatamart.com

Donate: To Support US

© 2024 GDATAMART.COM (All Rights Reserved)