Variables:
A variable is a name given to the storage memory; the variables are declared with a data-type which represents the type of data needs to be stored in the variable.
- It contains a value which is to be stored in the memory.
- Those values are then used in a program and they undergo a set of operations.
Example:
int number = 10;
In the above line,
- The “int” represents the data type of the variable.
- The “number” represents the name of the variable.
- The “10” represents the value of the variable.
Rules to naming a variable:
To name a variable, it should undergo certain criteria; they are as follows:
- A variable name should not start with any numeric digits.
- The keywords are not to be named as a variable name.
- A variable does not include any special characters.
- A variable can contain alphabets, digits and underscore.
The variables that do not meet the above criteria are considered as illegal variables.
Explanation of Solution
Identifying the illegal variables:
Consider the variable “Int”,
- It is a legal variable, because a variable name can be a string.
Consider the variable “char”,
It is an illegal variable, because a char is a data type.
Consider the variable “6_05”,
- It is an illegal variable, because a variable name should not start with any numeric values.
Consider the variable “Calloc”,
It is a legal variable, because a variable name can be a string.
Consider the variable “Xx”,
It is a legal variable, because a variable name can be a string.
Consider the variable “alpha_beta_routine”,
It is a legal variable, because a variable name can be a string.
Consider the variable “floating”,
It is a legal variable, because a variable name can be a string.
Consider the variable “_1312”,
- It is an illegal variable, because a variable name should not start with any numeric values or underscore values.
Consider the variable “z”,
It is a legal variable, because a variable name can be a single character.
Consider the variable “ReInitialize”,
- It is a legal variable, because a variable name can be a string.
Consider the variable “_”,
- It is an illegal variable, because a variable name should not start with underscore values.
Consider the variable “A$”,
- It is an illegal variable, because a variable name should not contains special character.
Therefore, in the given variables, the illegal variables are “char”, “6_05”, “_1312”, “_” and “A$”.
Want to see more full solutions like this?
- Suppose the value of b is false and the value of x is 0. What is the value of each of the following expressions?arrow_forwardIdentify the correct variable name from the following? a. Inflation high O b. high Inflation O c. highlnflation O d. 5highpricearrow_forwardWhat is the output of the following code segment?inta=3,b=4;if(a==b);Write(X);Write(Y); X Y XY nothingarrow_forward
- Which of the following statements is True? a. Floating point addition is not generally associative which can be seen when values differ greatly in magnitude, the smaller value tends to be zeroed out or may lose significant digits when making the exponents the same. b. Floating point addition is generally associative which can be seen when values differ slightly in magnitude, the larger value tends to be zeroed out or may lose significant digits when making the exponents the same.arrow_forwardTrue or false? The argument for trigonometric functions represents an angle in radians.arrow_forwardTrue or false? The argument for trigonometric functions is an angle in radians.arrow_forward
- For the given the following code segment, what is the output? And Why?arrow_forwardThis program includes a number of int variables: a, b, c, d, e, i, j, and y. Which of these variables could be printed by the first println statement? Which of them could be printed by the second println statement? Which of them could be printed by the third println statement? Which of them could be printed by the fourth println statement? Which of them could be printed by the fifth println statement? Which of them could be printed by the sixth println statement?arrow_forwardAre the following programs correct? If not, correct them.arrow_forward
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage