MCQs Test!! VB Basic Test !! Essentials of VB !! Creating User Services !! function !! Anatomy !! GK March-2019 !! DATA TYPES IN JAVA !! Classes ,Constructor ,Methods,Inheritance !! Ecology-I !! Biology 2019 !! Gk april 2019 !! Biology (living world) !! Plant anatomy !! CELL STRUCTURES AND FUNCTION !! General biology !! Human physiology !! Data structure !! Ecology-II !! GK TEST !! Reproduction in plants !! Human reproduction !! The ABC of C !! Operating system set1 !! Operating system set2 !! Gk and current affairs !! Animal kingdom !! Number system !! Animal kingdom-II !! Gk TEST-III !! Number series !! Microorganisms !! Interview question in c !! Time and Work !! Percentage !! General history !! Average !! Cells !! Locomotion and Movement !! paging !! Bacteriology !! Page replacement policy !! Secondary memory and Disk scheduling !! Introduction of Nervous System and neurons !! Plant harmones !! Transport and Mineral Nutrition in Plants !! Neurotransmitters !! Modern Indian History !! Photosynthesis in Plants !! Modern Indian History-II !! Plant respiration !! Environment & Biodiversity !! Environment & Biodiversity - II !! Algae, Bryophytes, Pteridophytes !! Area !! Cricket !! Days of the Year (India and the World) !! Plant Pathology - I !! Indian Transport System !! Plant Pathology - II !! Aptitude !! Biology !! Botany !! C language !! Computer Science !! Core Java !! Gate !! GK !! Mysql !! Operating system !! Physics !! VB-Visual Basic !! Zoology

C++ language

Previous Home Next

A variable is the temporary storage space in memory stored by its value. variable can be represented by their name,

The variable name can be any think like set of one or more letters, digits or underscore

Rules for defining variable name

  • A variable name can have set of letters or digits or underscore
  • A variable name can't have White space, punctuation symbols or other characters .
  • A variable name must begin with a letter.
  • Keywords or any reserved words cannot be of variable names.
  • Variable names written in capital letters and small letters are different variable because C++ is a case-sensitive language

Declaration of variables.

before declaring a variable first should think about data type of variable and also the name of the variable .Name of the variable should have some meaning .Data type in C++ is as:


data_type  variable_name;

short int: used to represent short integer.

int: used to represent integer.

long int: used to represent long integer.

float: used to represent floating point number.

double: used to represent double precision floating point number.

long double: used to represent double precision floating point number.

char: used to represent a single character.

bool: used to represent two values: True or False.

Type Size Values
unsigned short int 2 bytes 0 to 65,535
short int 2 bytes 32,768 to 32,767
unsigned long int 4 bytes 0 to 4,294,967,295
long int 4 bytes 2,147,483,648 to 2,147,483,647
int 4 bytes 2,147,483,648 to 2,147,483,647
unsigned int 4 bytes 0 to 4,294,967,295
char 1 byte character values
bool 1 byte true or false
float 4 bytes 1.2e38 to 3.4e38
double 8 bytes 2.2e308 to 1.8e3
 #include <iostream>	//include header file
  using namespace Beg;
 int main()		//main function with int return type
	  int a;	// declaration
	  int sum=0;
	   // declaration
	  cin>> a;	//object of in stream
   	cout << "value of a is.\n"
	,a;	//object of output stream
	sum= sum+a;
	 cout << "sum is.\n"
	 ,sum;		//object of output stream
	return 0;//return function

value of a.10
sum is.10

Reference Variable: A reference variable provide an alias (alternative name) for a previously defined variable name.

data_type & reference_name = variable_name;

Previous Home Next