C++ variable

 C++ Variable

Variable is the name of memory location where we store value. It is used to store data. Its value can be changed and it can be reused many times.

Syntax to declare a Variable

data-type variable name;

example's 

  • int a;
  • float b;
  • char c;

here a, b, and c are variables and int, float, char are data-types

                                                 Rules for defining and declaring variables

  • A variable can have alphabets, digits and underscore.
  • A variable name can start with alphabet and underscore only. It can't start with digit.
  • No white space is allowed within variable name.
  • A variable name must not be any reserved word or keyword e.g. char, float etc.
Valid variable name:-

  • int x;
  • int _xy;
  • int  x12;

Invalid Variable name:-
  • int 3x
  • int a b;
  • int char;

Comments

Popular posts from this blog

C++ Tutorial

My Social Media Account