Assigning Values to Variables Assignment Help

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

Assigning Values to Variables

A Value can be assigned to variables using the assignment operator (=): -

            var_name=expression;

An expression can be a single constant or a combination of operators, variables and constants. The statements:

p1=3250.00;   (the expression is a single numeric constant)

p2=4570.00;

p3= p1+p2;    (the expression is a sum of price1 and price2)

are known as assignment statements. Each statement must have a colon at the end. A statement implies in which the value of the variable on the left of = is set to the value of the expression on the right. Thus,

count=count+1;

implies in which the 'new value' of count (left side) has been set to the 'old value' of count plus 1 (right side).

The variables can be assigned a value at the time of the declaration itself. This is known as initialization. The common format is: -

Data-type var_name=constant;

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