+ 1

Useful Example of Variables in a Program

i can't really imagine the use of a variable in a program. I know what it does and how it works but i would be pleased if someone can show me an example and how it works in a specific program function.

10th Jun 2017, 1:52 PM
Cynx
Cynx - avatar
3 Answers
+ 10
We have had such cases. https://www.sololearn.com/Discuss/432174/?ref=app The uses of variables are too essential and obvious for one who understands to be able to effectively convey through few lines of answer. My advice is for you to get into programming and solve problems/questions ASAP so you will get it naturally, as to why variables are used.
10th Jun 2017, 2:30 PM
Hatsy Rei
Hatsy Rei - avatar
+ 3
imagine having a 10000 line of coding in which one of the key things you need is the price of an item, which you must use to calculate a price a customer has to pay if they bought different items. You will definitely need a variable to store a price value and and every time you need to use the value you will just call the variable. Sometimes you find out that the user needs to compute with their own values, you will have to store their value in a variable and when ever you need to use their value you just have to call it. Rating change too, today it changes occasionally that means you will have to occasionally change too on your 10000 line of coding! A variable can save you all the stress because you know that you'll definitely go to a place where you stored your variable and make that necessary change on just a single line of coding instead of searching each of the 10000 lines.
10th Jun 2017, 2:05 PM
Thabo Roy
Thabo Roy - avatar
+ 1
Thanks to Thabo. This answered my question! :)
10th Jun 2017, 2:36 PM
Cynx
Cynx - avatar