|int||Numeric – Integer||-2 147 483 648 to 2 147 483 647|
|float||Numeric – Real||-3.4 * 1038 to 3.4 * 1038|
|double||Numeric – Real||-1.7 * 10308 to 1.7 * 10308|
|char||Character||All unicode characters|
|bool||Boolean||True or False|
int i = 5;
Alternativly, you can write as shown below.
In C++, A variable can also be a signed variable or an unsigned variable. Signed means that it can have negative numbers and unsigned means it can't but unsigned gives a variable a greater positive range.
unsigned int i;
To give the variable a smaller or bigger range respectively, you need to put short or long keywords. Example:
short int i;
A string is a type of variable that can store multiple words. You can declare a string in three ways. The first is to declare it as a string pointer by using * symbol. The * means that it points to the first character of the string.
s = "Hello";
The second way is to declare it as an array of characters which you must set a size when you declare it. You have to use the strcpy command to assign values to it. You must also include the string header file to be able to use the strcpy command.
The last way is to use the string data type.
string s="C++ programming";
This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages: