Technologies

C

C Languages Assignment Operators
(adsbygoogle = window.adsbygoogle || []).push({});

(adsbygoogle = window.adsbygoogle || []).push({});
(adsbygoogle = window.adsbygoogle || []).push({});

CLanguage

Friday, 31 Mar 2017

113

0

0

**Assignment Operators : **Assignment operators are used to assign the results of an expression to a variable. In addition to usual assignment operator, C has a set of shorthand assignment operators.

syntax for assignment operator : var = exp

syntax for shorthand assignment operator : var op = exp

syntax for shorthand assignment operator : var op = exp

where var is variable, exp is an expression and op is a C binary arithmetic operator. The operator op = is known as the shorthand assignment operators.

the assignment t statement : **var = var op exp** is equivalent to : **var op = exp**

Assignment Operator |
Shorthand Assignment |
Meaning of both operators |
---|---|---|

a = a + 1 | a += 1 | adds 1 to a and assigns the value to a |

a = a - 1 | a -= 1 | subtracts 1 from a and assigns the value to a |

a = a/(b + 5) | a/= (b+5) | divides a by b+5 and assigns the value to a |

a = a * (b+5) | a *= (b+5) | multiplies a by b+5 and assigns the value to a |

Invalid assignment statements : **2 = 5 + 3; 2 = b;**

Assignment operator is a binary operator.

Assignment operator follows right to left associativity.

The use of shorthand assignment operators has three advantages :

- What appears on the left-hand side need not be repeated and therefore it becomes easier to write.
- The statement is more concise and easier to read.
- The statement is more efficient.

Post Article

Upload Youtube Video

CLanguage

Friday, 31 Mar 2017

113

0

0

Popular Post

- Write an algorithm and draw the flowchart to find the largest number among the three numbers?
- Write an algorithm an draw flowchart to find factorial of a number?
- Write an algorithm and draw the flowchart to find whether a given number is even or odd?
- Write an algorithm and draw the flowchart to Swap two integers?
- Write an algorithm an draw the flowchart to compute the average of the three numbers?
- Write an algorithm and draw the flowchart to find the largest number amoug two numbers?
- write a c program to swap two numbers
- How to write a algorithm?
- What is mean by Operator Precedence and Associativity in C Language?
- C Languages Relational Operators

© 2019 - technotecode. All contents are copyright of their authors