What Is Variables And It's Data Types ? || Explained With Real Life Example || Variables and datatypes in C++
VARIABLES AND IT'S DATATYPES IN C++
What is a variable?
A variable is a space in your memory in which you can store data. Variables allow you to use that stored data in the future in your program. You can create a variable in the program and then you can use it.
Understanding Variable With A Real-Life Examples -
To get a more clear understanding of the variable let me explain this concept with a real-life example. As you have a kitchen in your home, in the kitchen you may have some boxes in which you can store sugar, salt, chili, etc. and if the boxes are not transparent and same then probably you put a label on it in which you write what is inside in this box, and you can use these boxes to store some kind of ingredients or masala, so you can use it in future.
So same as you are doing in your kitchen you can do this in programming also. As you have boxes in your kitchen , same in programming you have memory in your CPU. As you store some ingredients in the box, same in programming you stores some data (in binary) in memory. As you labled your boxes, same you can lable your memory in programming to recall it.
I hope till now you understood what is a varaible.
And if you want to know more about the variables then here you have the official definition of variables -
In computer programming, a variable or scalar is a storage location (identified by a memory address) paired with an associated symbolic name, which contains some known or unknown quantity of information referred to as a value.
How to create variables in C++?
DATATYPES -
WHAT IS DATATYPE?
Data type - as name sounds type of data. So there are many types of data we can store in a memory or now you can say in a variable. Here are the types of the data -
- int - Integer
- float - Floating-Point
- double - Double Floating-point
- char - Character
- bool - Boolean
- void - Empty
How to create variables of different data type in C++?
So that's all for this post. In future posts, you will learn more about the C++ programming language.
Hope you like this post, If you like then follow our blog and if you have any suggestion or query then you can write it in the comment section, I'll try to help you there.
Comments
Post a Comment