In this tutorial Variable Declaration in C++.Complete guide Variable and Variable Declaration. I hope
Easy to Understand.Best of luck.
Question :
- What are Variables?
- Difference between Variables and Data-Type?
- What is Data-Type?
- Char difference between String?
C++ Variables:
Variables are containers for storing data value. In c++, there are different types of variables.other types of variables two main types, Global Variable, Local Variable.
For Example:
- Int
- Char
- Bool
- Float
- Long
- String
- Double
Difference Between Variable and Data Type:
Variables Store Information data type store specific information to be store variables
For Example:
string name = "Jack"
Here string is a data type("string") and tells variables called name("name") to store text(Jack).
Explain Variable :
1).Int (Integer)
- Stor Integer Whole number
- Without decimal
- 123 to -123 Store
- 4-byte Size
For Example
- 1,2,12,45 are store whole number, not store point number
Not Example
- Numbers that are not integers 1.43, 1 3/4, 3.14, are different numbers.
Double OR Float
- Store floating-point numbers
- with decimal
- For Example
- 19.99 to -19.99
- 8 byte
Double and Float
Same Rule but the difference only float 32-bit floating-point data_type. A double 64-bit floating-point number.
Bool:
- Store Values with Two States
- Yes / NO
- ON /OFF
- True /False
Long
- store the integer data higher range
- 4-byte 32-bit system
- 8-byte 64-bit system
For Example
- long int a=-2147483648
Char(Character)
- store single characters
- such as 'a' or 'b'
- Char value is surrounded by single quotes
- 1 byte
- -128 to 127 or 0 to 255
For example
char letter = 'A';
String
- store text
- such as "Hello World"
- String values are surrounded by double quotes " -- "
For Example
- string myText="Hello"
store text hello
Difference Between String and Char
Char VS String
1).Char
- #include <iostream>
- using namespace std;
- int main () {
- char myGrade = 'B'; //char only use single quotes '-------'
- cout << myGrade;
- return 0;
- }
2).String
- #include <iostream>
- using namespace std;
- int main () {
- char myGrade = "B"; //char only use double 7 quotes '-------'
- cout << myGrade;
- return 0;
- }
To understand the point.
Watch Video
Post a Comment
Virtually nothing is impossible in this world if you just put your mind to it and maintain a
positive attitude.