answersLogoWhite

0

Why does programmer need variable?

Updated: 8/10/2023
User Avatar

Wiki User

10y ago

Best Answer

Variables can maintain the same value throughout a program, or they can change values several times, depending on your needs. when you put a variable in a program, the computer recognises the variable and you can change it's value throughout without an error. Note: You can write programs without variables, but their functionality will be quite restricted, like this:

int main (void) { puts ("hello, world"); return 0; }

User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago

In any progarm we typically do lots of calculations.

The results of these calculations are stored in computer's memory.

Like human memory, the computer's memory also consists of millions of cells.

The calculated values are stored in these memory cells.

To make the retrieval usage of these values easy these memory cells also called memory locations are given names.

The names called Variable names.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

Mainly, use to store data.

variable is just like a data structure.

we save our values and data in variables to operate them.

we can make our programs without variables variables but in a very restricted way.

variable are vry important in our programs.

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

When programming, if variables aren't used, a program is quite literally 1 dimensional, if you were to make a calculator, you would have to reprogram it every time you wanted to calculate something. Eg:

say you wanted to work out 5 by 5, (In batch programming, in this scenario)

your program would look something like this:

@echo off

set /a answer=5*5

echo %answer%

pause

Notice that even then you need to make a variable for calculations, but that is due to the simplicity and convenience of batch.

This program would set a variable to 5 multiplied by 5 and then display that variable using echo %answer%

pause just means it would wait for you to 'press any key to continue' and then close.

However, say you wanted 7 times that amount in the end, you would have to remake the program.

@echo off

set /a answer=5*5*7

echo %answer%

pause

So if you were to make a program that involved variables (In terms of a normal programming language) it would be a lot more convenient:

@echo off

set /p A=Define first variable. ;Sorry about the pun

set /p B=Define second variable

set /p op=Define operation (+ - * % or /)

set /a answer=%A%%op%%B%

echo

This program would ask you to define each of the variables before making and algorithm out of those variables to calculate and then display.

Variables are the first step into making a smarter and efficient program that is either more user friendly or can judge it surroundings to work out how to get around some of the more complicated problems in life.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago
Advantages of Variable in Programming.As we know that Variable is a place where data is stored and retrieved while its is required. In the context of Programming, we must have to create a variable to store our input data for processing. we can point out its advantages as below.
  • Variable helps us to store data
  • Data stored in variable may be String or Numeric.
  • Variable also can store Constants that can be changed during program execution.

Mr. Gauro

Nepal Engineering and Technical Science Academy.

Birendranagar, surkhet

Nepal

This answer is:
User Avatar

User Avatar

Wiki User

6y ago

A variable is an object we use to store and manipulate information. Variables are either constant or mutable. A constant variable cannot (easily) change value once initialised whereas a mutable variable's value can always be changed at any time, or it can be left uninitialised. All variables can be copied and mutable variables can also be moved.

Variables can be named at design time however variables allocated on the heap are generated at runtime and therefore cannot be named; they are anonymous. However, all variables have an address thus we can refer to them by that address.

Variables passed to functions are always passed by value which means the value is copied and assigned to the function's formal argument, which is another variable. However, if we wish to pass the variable itself, rather than it's value, then we must pass the variable by reference, which means we pass the address of the variable rather than its value. To pass an address into a function, the function's formal argument must be a reference or pointer variable. A pointer variable is a special type of variable that is used purely to store a memory address and refer to the value stored at that address (also known as pointer dereferencing). A reference is not a variable, it is merely an alias (an alternate name) for a variable, in the same way that Tom is an alternate for someone called Thomas (they both refer to the same person).

This answer is:
User Avatar

User Avatar

Wiki User

10y ago

Without variables, programs would not be able accept or process user data. In essence, a new program would have to be written each time new data was used, which would make software useless. Variables allow programmers to input data from keyboards, mice, networks, and so on, and output data to screens, printers, and so on. Variables are one of the key elements of programming, which without programs could never be useful.

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

Storing data, especially variable (ie not constant) data.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

Strictly speaking, you are not bound to use variables, but they can be very useful in programming.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Why does programmer need variable?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What does the variable paltnew represent?

Whatever a programmer wants it to represent.


What are identifying variables?

the variable which can be identified by the programmer are called identified varibles


How do you make a 99 dodge cummins 3500 blow out black smoke?

You will need to buy a programmer for the computer.You will need to buy a programmer for the computer.


Do you need to be an excellent programmer to be an engineer?

No.


How do you burn the software on a 8051 microcontroller?

You will need a 8051 device programmer that connect to a PC with software to drive the programmer


Do you need to go to college for a computer programmer?

yes


Do you need to go to college to become a computer programmer?

no


How can you make your 2001 Chrysler 300m pass your governor mph?

You will need to reprogram the computer with an upgrade programmer.You will need to reprogram the computer with an upgrade programmer.


How do you make a game for the moshi fun park on moshi monsters?

You would need to be someone who is a computer programmer or a game programmer.


Do I need special education to get in to the tax software business?

If you are creating basic software the only thing you would need to know is how to program. If you are not a programmer, but are a tax specialist you just need to find a programmer to help you.


How can you make a evil hacking machine like the one from the anime tottaly spys?

First you need a computer, then you need a supergenius programmer, pay the programmer alot of money to build you one.


What types of variables are useful to programmer?

All variable types in a given computer language are useful to a programmer, otherwise they would not be included in the language. However, a specific program may not need to use all types to solve a given problem.In general, there are two distinct categories of variable types: primitive types and derived types.A primitive variable type is one whose definition is stated by the program language itself. Common primitive variable types are Integers, Characters, Floating Point numbers, and Arrays. The meaning of these types is fixed, and cannot change. Most languages seldom have more than a half-dozen primitive variable types.A derived variable type is one which is created by combining two or more primitive types together. It is possible to create a huge variety of different derived variable types. Items such as HashMaps, Strings, and Linked Lists are common derived variable types.