+ 10
Why do I need a variable in code?
19 Réponses
+ 12
You need variable to hold or to store data.
Try to make a program that
asks for the users age
and print the age of the user to screen.
You need to store the value that the user gives
and you need to retrieve this value when you want to print it to the screen.
That is what variables are used for.
+ 16
variable are container for storing info ...you need variable to store so e data
+ 10
To save memory used by your programs😉
To make works easier
+ 8
You need it whenever you want to store any value for later use.
For example you want to write a program where the user enters his name and you tell him how many letters it has.
First the user input has to go somewhere so that later you can count the letters.
And the 'pot' where you put the name is a variable.
+ 7
Variables are used to store information to be referenced and manipulated in a computer program. They also provide a way of labeling data with a descriptive name, so our programs can be understood more clearly by the reader and ourselves. It is helpful to think of variables as containers that hold information. Their sole purpose is to label and store data in memory. This data can then be used throughout your program.
+ 6
Variables hold the data your code works with.
+ 5
Without variables you may need a new program for every new situation and set of data and you might as well not use a program.
+ 4
if you want to gate input from user, you need to create new variable. Apart from that, you need some storage to keep your input, so that variable is needed. if you don't have any variable, you will have to write every time when you need some data to be entered in your program. In short, you can do nothing without variable:))
+ 3
Variables are used to store values or data...for e.g....x is my var and I want to store 10 in x..then int x=10;
+ 3
So as to represent a number with an alphabet and it will be easier to use. E.g: let a=2
A+2
Result:
4
U see here i am representing it with an alphabet
2. It can be used to store values i.e example 1 above
3. To hold or store data
+ 2
Variable is a named location in a memory where a program can manipulate a data. This location is used to hold the variable.
+ 2
You need variables in C++ to store values. If you make something like a video game with a level system, how will you store the values? Without variables, it's a 1-time thing. If you have a number you have to find out its value later, you use a variable. Without variables, most programs wouldn't be possible.
+ 2
Variable is needed to store values in order to do various operations
+ 1
Variable is very necessary to a program because it is used to store a value for the integers characters et cetera
+ 1
Variable should not be a keyword
+ 1
To make a programs , web pages , design of something or video game.
0
Variables are used to store data and access data from memory
You can easily access data from memory by variable name
0
Imagine you didnt have variables, it would make life very difficult; take these simple exaples:
imagine you wanted to write a clock app that told the user the time. you would have to release one app for every time zone in the world; the user wouldn’t be able to use the app if they went on holiday to a different time zone.
imagine you wanted to add an alarm clock, you would need a variable to allow the user to store the time at which they wanted the alarm to go off
think of all the apps for your device - you couldn’t add new ones without variables to remember whcih apps you’ve added or bought
the list is endless...