programplug Logo




C++ Variables


» A variable is a memory location (Name Where Data Store).It Use For Storing Data.
» It's value can be changed and reused many times
» It is a way to represent memory location by using symbol,so it can be easily identified.

Rules for defining variables
» Use alphabets, digits and underscore.
» No white space is allowed
» Name must not be any reserved keyword


int a;
int my_age;
double add;


Types of Variables in C++

1.Local variable
2.Global variable
3.Static variable
4.External variable


Local variable
A variable which is declared inside the function is called local variable.It mis declared at the start of the block.


void main()
{  
  int a,b=20,c;    //It Is Local variable 
}

Global Variable
A variable which is declared outside the function or main is called global variable.The value of the global variable can change .


int a=10,b=4,c=40;       //It Is Global variable  
void main()
{  
  int x=10,y=20,z=30;   //It Is Local variable  
} 

Static Variable
A variable that is declared with static keyword is called static variable.


void main()
{  
 int a=20,b,c=30;           //It Is Local variable  
 static int x=100;         //It Is Static variable  
 x=x+1;  
 a=a+1;  
 c=c+1;    
cout<<"Value Is:";
cout<<"Value Is:";
cout<<"Value Is:";
}





Our Services

Developing Cheapest Websites
Offer Digital Marketing
Provide College Projects
Attractive Website Developing
Summer Training,Industrial Training
SCO,SMO

Contact Us

Dehradun Uttarakhand India
www.programplug.com
info@programplug.com
000000000

Other Link

About Us

Contact Us

Disclaimer

Privacy Policy