Variable in C++

Advertisements

Prev Tutorial Next Tutorial

Variable in C++

Variable is an identifier which holds data or another one variable is an identifier whose value can be changed at the execution time of program. Variable is an identifier which can be used to identify input data in a program.

variable images

Syntax

Variable_name = value;

Variable declarations

This is the process of allocating sufficient memory space for the data in term of variable.

Syntax

Datatype variable_name; int a;
variable declaration rule in c++

If no input values are assigned by the user than system will gives a default value called garbage value.

Garbage value

Garbage value can be any value given by system and that is no way related to correct programs.
It is a disadvantage and it can overcome using variable initialization.

Variable initialization

It is the process of allocating sufficient memory space with user defined values.

Syntax

Datatype nariable_name=value;

Example

int  b = 30;
variable initialization images

Variable assignment

It is a process of assigning a value to a variable.

Syntax

Variable_Name = value

Example

int  a= 20;
int b;
variable Assignment

Example

b = 25; // --> direct assigned variable
b = a;  // --> assigned value in term of variable
b = a+15;  // --> assigned value as term of expression
variable Assignment images
Prev Tutorial Next Tutorial

Advertisements

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Pure VPN Privide Lowest Price VPN Just @ $1.65. Per Month with Non Detected IP Lowest Price Non Detected IP VPN

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements