Variables are certain data types which can store values during execution of the program.The values stored in variables can be changed during the program execution.For eg. a,b,d etc.
Declaration of Variables
In order to create use of a variable in C++, they need to first declare it specifying which data type they need it to be. The syntax to declare a new variable is to write the specifier of the specified data type (like int, bool, float...) followed by a valid variable identifier.Various data types are as followed:
Name Description Size* Range*
char Character or small integer. 1byte signed: -128 to 127 unsigned:0 to 255
short int(short) Short Integer. 2bytes signed: -32768 to 32767
unsigned: 0 to 65535
int Integer. 4bytes signed: -2147483648 to 2147483647
long int (long) Long integer. 4bytes signed: -2147483648 to 2147483647
unsigned: 0 to 4294967295
bool Boolean value. 1byte true
float Floating point number. 4bytes +/- 3.4e +/- 38 (~7 digits)
double Double precision floating 8bytes +/- 1.7e +/- 308 (15 digits) point number.
long double Long double precision 8bytes +/- 1.7e +/- 308 (15 digits) floating point number.
Declaration of Variables
In order to create use of a variable in C++, they need to first declare it specifying which data type they need it to be. The syntax to declare a new variable is to write the specifier of the specified data type (like int, bool, float...) followed by a valid variable identifier.Various data types are as followed:
Name Description Size* Range*
char Character or small integer. 1byte signed: -128 to 127 unsigned:0 to 255
short int(short) Short Integer. 2bytes signed: -32768 to 32767
unsigned: 0 to 65535
int Integer. 4bytes signed: -2147483648 to 2147483647
long int (long) Long integer. 4bytes signed: -2147483648 to 2147483647
unsigned: 0 to 4294967295
bool Boolean value. 1byte true
It can take one of two or false
values: true or false.
float Floating point number. 4bytes +/- 3.4e +/- 38 (~7 digits)
double Double precision floating 8bytes +/- 1.7e +/- 308 (15 digits) point number.
long double Long double precision 8bytes +/- 1.7e +/- 308 (15 digits) floating point number.
Wednesday
//
Labels:
c++
//
0
comments
//
0 comments to "Variables"
Powered by Blogger.
Post a Comment