Which function is used to take the value of variable from user after execution of program? *
Answers
Answer:
Variables in a computer program are analogous to "Buckets" or "Envelopes" where information can be maintained and referenced. On the outside of the bucket is a name. When referring to the bucket, we use the name of the bucket, not the data stored in the bucket.
Variables are "Symbolic Names". This means the variable "stands in" for any possible values. This is similar to mathematics, where it is always true that if given two positive numbers (lets use the symbols 'a' and 'b' to represent them):
a + b > a
(i.e., if you add any two numbers, the sum is greater than one of the numbers by itself).
This is called Symbolic Expression, again meaning, when any possible (valid) values are used in place of the variables, the expression is still true.
Another example, if we want to find the sum of ANY TWO NUMBERS we can write:
result = a + b;
Both 'a' and 'b' are variables. They are symbolic representations of any numbers. For example, the variable 'a' could contain the number 5 and the variable 'b' could contain the number 10. During execution of the program, the statement "a + b" is replaced by the Actual Values "5 + 10" and the result becomes 15. The beauty (and responsibility) of variables is that the symbolic operation should be true for any values.
Another example, if we want to find out how many centimeters tall a person is, we could use the following formula: height in centimeters = height in inches * 2.54.
This formula is always true. It doesn't matter if its Joe's height in inches or Jane's height in inches. The formula works regardless. In computer terminology we would use:
height_in_centimeters = height_in_inches * 2.54;
% the variable height_in_centimeters is assigned a
% new value based on the current value of "height_in_inches"
% multiplied by 2.54