Register | Sing In

New posts

Stacks in C programming Linked Lists in C programming File Input/Output in C programming Check prime numbers in C Programming C Programming Enumeration C Programming Union

Archives

2013-10 2013-09 2013-08

Assignment Operators in C programming

August 13, 2013 Posted by: GPA Views: 591 0 comments

C has assignment operators for abbreviating assignment expressions. For example, the statement

i = i + 1;

The += operator adds 1 to the value of the variable on the left of the operator and stores the result in the variable on the left of the operator. What it mean?

Assume i=3 the if we use the statement

i = i + 1;

then the result will be 4.

This table shows the arithmetic assignment operators, sample expressions using these operators and explanations 

Assignment operator Sample expression ExplanationExample
+= a+=5 a=a+5 Assume: a=2, result will be 7
-= a-=5 a=a-5 Assume: a=7, result will be 2
*= a*=2 a=a*2 Assume: a=2, result will be 4
/= a/= a=a/2 Assume: a=2, result will be 1
%= a%= a=a%9 Assume: a=12, result will be 3

0 Comments...

Leave a Reply

Please, Sing In to leave a Reply for this material.



Online Chat

LiveZilla Live Help

Popular posts

Function strtok in C programming Check prime numbers in C Programming C Programming Union Linked Lists in C programming File Input/Output in C programming C Programming Enumeration

RSS-subscribe

New materials

Subscribe