Saturday, 20 June 2015

Basics of Programming

Every memory location is given a name. This name is called variable. When we consider variable, it have some kind of data types which are attached to them. All data should be of certain number of bytes to which we call one word. For eg., int is of 4 bytes

Instructions perform operations.
Steps:

  • Pick instruction in sequence
  • Get the value of variables
  • Perform operations
  • Store the results
  • Go back and pick next instructions
Equal symbol is called the assignment operator. 


Variable is something that can change during execution of a program but constant cannot.
Variable names are case sensitive. Maximum size for variable name is 31. Keywords are reserved words.

While using operators, it is good practice to use parenthesis rather than relying on precedence rule, although this rule works. Expression is evaluated from left to right.

Precedence rule:

  1. Parenthesis and sub-expressions
  2. *, / , %
  3. +, -

Unusual Operators:
Using increment (++) and decrements (--) operator

Let n= 4;
a=n++;
b=++n;

n=4, a=4, b=6, n=6





No comments:

Post a Comment