Tuesday, 24 February 2015

Procedural Programming ( operators)

The Assignment Operators

In C, the assignment operator is the equal sign = and is used to give a variable
the value of an expression. 
For example:

  1. i=0;
  2. x=34.8;
  3. sum=a+b;
  4. midinit='J';
  5. j=j+3;
When used in this manner, the equal sign should be read as “gets”. Note that
when assigning a character value the character should be enclosed in single
quotes.

In the assignment statement

a=7;

two things actually occur. The integer variable a gets the value of 7, and the
expression a=7 evaluates to 7
. This allows a shorthand for multiple
assignments of the same value to several variables in a single statement. Such
as

x=y=z=13.0;

as opposed to
x=13.0;
y=13.0;
z=13.0;


The following example illustrates two methods for variable initialization:



which produces the following output:


 Any question about assignment operators writes down in comment box. Everyday check this blog u will learn lot things of C programming and Web application development 

No comments:

Post a Comment