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_forwardSelect all alternatives that are correct related to variable names. a. It can have symbols in the middle or at the end. O b. It can not have digits at the end. C. It cannot start with a symbol, except__. O d. It can start with a digit. e. It can start with a capital letter.arrow_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 is an angle in radians.arrow_forwardWhich of the following is not a correct variable type? (a) Float (b) Real (c) Int (d) Double (e) Char.arrow_forward
- which of the following statements are true?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
- Which of the following statements about Python expressions is true (choose all that apply). a. In mathematical expressions, the operand can be a mathematical expression itself. b. The assignment operator (-) has higher precedence than subtraction (-). c. To negate a value of a variable you use the (--) operator. d. In Python operators such (--) and (-) allow you to compare between values of different variables.arrow_forwardFor the given the following code segment, what is the output? And Why?arrow_forward2. Express the following Boolean expressions in simpler form; that is, use fewer operators. x is an int. (e) x 20arrow_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