+ 1
I donāt know the exact mean of variable can some one explan me ?
6 Answers
+ 4
Think of them like box's say we have int x = 100;
ā¬
"int" āŖ this box š¦ is for numbers
xāŖ is the š· attached to the number š¦ with x written on it
= means store this
100 in number box š¦ labeled š· x
If we open the box labeled x inside theres the value 100 so we now know box/variable x = 100 š
+ 2
very nice tanks
+ 1
To put it as simple as i can.. A variable is like a container for some kind of value, it can be an integer value like ā10ā, a float/double value like ā10.23ā, can be a single char or an entire string value like āhello! iāam a variableā, or a boolean value that is ātrueā or āfalseā.
When we declare a variable, the variable will request some space in the memory to store the value it is meant to..
If we declare an int variable like: int a = 3; then the variable will request the space in the memory to hold the value ā3ā. Variables after are declared, can be used and modified all the time we need in our program!
+ 1
thanks a lot i get it
+ 1
Variable is like a basket you can put number and characters in it
First step
What kind of thing you put in variable if you want to put integers then you use "int"
Second step
name of you variable
Let take "a" as name of variable
So let's creating variable program
Int main()
{
Int a;
cout << "Enter number in variable ";
cin >> a;
cout << a;
}
Explainion
cin >> a
Takes number you want to store in variable
And
cout << a
Print the number you store in the variable