Variables & Identifiers in c++ languages .

                                                                        Variables



Just as in C, there are different types of variables defined with some specific keywords. Variables are defined as 'a data item that may take on more than one value during the run time of a program'. Variable has to be of a specified data type.

 

int: Stores all kinds of integers e.g. 12, 873

double: Stores floating point numbers which are decimals e.g. 12.3, 16.1
char: Stores single letters, or we can say characters of a string e.g. 'G', 'g'

string: Collection of characters makes a string. These are written in double quotes e.g."Demo Code"
bool: Stored values are either true or false. Shorthand for 'Boolean'.

 

How to declare a Variable?

Just as in C, we need to mention it's data type followed by the variable and equate it to it's value. However assigning a value to the variable is not necessary.

Syntax :        

type variable= value;       
example - int sahil=5;

Comments

Popular posts from this blog

In C++ Syntax

Add two number using class in c++ .

DATA types in C++ languages .