Assignment Operators Assignment Help

Assignment Help: >> Data Types, Variables and Operators in C++ - Assignment Operators

Assignment Operator

Assignment operator (=) is used to assign the result of an expression to a variable. It takes the form as: -

var_name = expression;

above given var_name is the name if the variable that will be assigned the value of expression through the assignment operator (=).

Example:

char name;

int a, b, c;

name = "Ashu";        /*  the  variable  name  is  assigned  the  value, Ashu */        

a = 12; /* a is assigned the value 12 */

b = 98;            /* b is assigned the value 98 */

 

c = a + b         /* c is assigned the sum of a and b */

Further to this, C++ has a set of 'shorthand' assignment operators of the form:

var_name oper= expression;

oper is a binary arithmetic operator. The operator oper=   is known as the 'shorthand' assignment operator. The assignment declaration var_name oper= expression is equivalent to

var_name = var_name oper expression;

Example:

count = count + 1;

is equivalent to

count+ = 1;

The shorthand operator += means ' increment count through 1'.

More examples

2137_assignment operator.png

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd