0
i cant understand what is variable!
9 Answers
+ 3
Like people have said, a variable stores information, depending on the data type.
Data types include things such as "int" (integer), for whole numbers, "float" for decimal values, "double" for more precise decimal values, "bool" for true/false, "string" for a sentence, etc etc. These are some of the very basic data types for variables you will encounter, but you will find a lot more as you advance.
When creating a variable, we first write the data type (take "int" for example):
int
We then declare the variable name, to whatever you like. It would be ideal if variable names were not incredibly long, and that the name clearly states, as best as possible, what the variable is used for in the program:
int age
After this, we can choose to end the line with a ';'. Ta-da! Your variable is created! You can now manipulate it however you like, by using std::cin (to get input from the user), or simply do a line such as "age = 18;".
Or, we could choose do declare what data our variable holds as soon as we declare it:
int age = 18;
Hope that helps!
+ 1
Ha ha.
+ 1
how?
+ 1
variable is used to store a value
depending on the type of value we use datatype s into,float, char etc
egs
int a; //integer value is stored inside a
float a;//float value is inside a
char ch;
value can assign at the time of declaration
int a=0;
more variable (same type)can declare and initialize in a line as
int a,b;
we read the variable value while pgm is running
using read statements
+ 1
variable means which have the ability to change the digit.
0
variables are used to define or hold any value
0
like x and y? or 12345 etc? sorry i hate math. haha lol
0
thank you for that answer i read that carefully !
0
a variable is a identifier