What will the Basic statement for the following situations:-
1) Multiple 2 variables A and B store the result in C.
2)To store the name Abhinav in A.
3) To add random values of X,Y & Z.
Answers
Answered by
1
Variables
A variable is a symbolic name for (or reference to) information. The variable's name represents what information the variable contains. They are called variables because the represented information can change but the operationson the variable remain the same. In general, a program should be written with "Symbolic" notation, such that a statement is always true symbolically. For example if I want to know the average of two grades, We can write "average = (grade_1 + grade_2) / 2.0;" and the variable average will then contain the average grade regardless of the scores stored in the variables, grade_1 and grade_2.
Variables - Symbolic Nature
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 positivenumbers (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
Variable actions
There are only a few things you can do with a variable:
Create one (with a nice name). A variable should be named to represent all possible values that it might contain. Some examples are: midterm_score, midterm_scores, data_points, course_name, etc.
Put some information into it (destroying whatever was there before).
We "put" information into a variable using the assignment operator, e.g., midterm_score = 93;
Get a copy of the information out of it (leaving a copy inside)
We "get" the information out by simply writing the name of the variable, the computer does the rest for us, e.g., average = (grade_1 + grade_2) / 2.
Examples of Usage
Below are some examples of how to use variables:
Matlab
C, Java
ActionScript
age = 15; % set the users age
age_in_months = age * 12; % compute the users age in months
age_in_days = age_in_months * 30; % compute the approximate age in days
student_name = 'jim'; % create a string (array of characters)
grades = [77, 95, 88, 47]; % create an arary
Variable Properties
There are 6 properties associated with a variable. The first three are very important as you start to program. The last three are important as you advance and improve your skills (and the complexity of the programs you are creating).
Memorize These!
A NameA TypeA ValueA ScopeA Life TimeA Location (in Memory)
Clarification of Properties
A Name
The name is Symbolic. It represents the "title" of the information that is being stored with the variable
A variable is a symbolic name for (or reference to) information. The variable's name represents what information the variable contains. They are called variables because the represented information can change but the operationson the variable remain the same. In general, a program should be written with "Symbolic" notation, such that a statement is always true symbolically. For example if I want to know the average of two grades, We can write "average = (grade_1 + grade_2) / 2.0;" and the variable average will then contain the average grade regardless of the scores stored in the variables, grade_1 and grade_2.
Variables - Symbolic Nature
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 positivenumbers (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
Variable actions
There are only a few things you can do with a variable:
Create one (with a nice name). A variable should be named to represent all possible values that it might contain. Some examples are: midterm_score, midterm_scores, data_points, course_name, etc.
Put some information into it (destroying whatever was there before).
We "put" information into a variable using the assignment operator, e.g., midterm_score = 93;
Get a copy of the information out of it (leaving a copy inside)
We "get" the information out by simply writing the name of the variable, the computer does the rest for us, e.g., average = (grade_1 + grade_2) / 2.
Examples of Usage
Below are some examples of how to use variables:
Matlab
C, Java
ActionScript
age = 15; % set the users age
age_in_months = age * 12; % compute the users age in months
age_in_days = age_in_months * 30; % compute the approximate age in days
student_name = 'jim'; % create a string (array of characters)
grades = [77, 95, 88, 47]; % create an arary
Variable Properties
There are 6 properties associated with a variable. The first three are very important as you start to program. The last three are important as you advance and improve your skills (and the complexity of the programs you are creating).
Memorize These!
A NameA TypeA ValueA ScopeA Life TimeA Location (in Memory)
Clarification of Properties
A Name
The name is Symbolic. It represents the "title" of the information that is being stored with the variable
srushtikharat357:
Actually I needed th ans in like this. PRINT A="234"
Similar questions