Skip to main content

Variables / Identifiers / Literals (Constants)

Variables

These are the memory location which can store a value. As the name suggests, the value of a variable can vary during the whole program.

In other words, variables are named storage locations whose value can be manipulated during program run.


Example: 

a = 5;  ✔

5 = a;  ✖

a = a + 2;

a = a + 10;

Identifiers

Name of variable, function, array, class etc created by the programmer are called as identifiers.

Constants

Data items that never change their value during a program run.
  • integer constant
  • character constant
  • floating constant
  • string-literal

Comments

Popular posts from this blog

Selection statement

  If statement  If tests a particular condition, if the condition evaluates to true then set of statements under the body of 'if' statement will be executed otherwise it will be ignored by the compiler. Syntax : if(<condition>) {      statements; } <> : programmer defined If else statement If we use 'else' statement with 'if' statement then if the condition of 'if' statement evaluates to false, in that case body of else statement will be executed, otherwise it will be ignored. Syntax :  if(<condition>) {      statements; } else {     statements; } If-else-if ladder If we use 'else if' statement with 'if' statement then if any condition evaluates to true, in that case its associated statement will be executed and all other 'else if' and 'else' statement will be ignored by the compiler. Syntax :  if(<condition>) {      statements; } else if(<condition>) {    statements; } els...