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?
- Which of the following is equivalent to the following statement?if(m==0)d=0; elsed=1; d=(m==0):d=0,d=1; m?(d=0);(d=1); m==0;d=0;d=1? d=(m==0)?0:1;arrow_forwardWhich of the following is true for variable names in C? Select one: a. Variable names can start with a digit b. They can contain alphanumeric characters as well as special characters c. It is not an error to declare a variable to be one of the keywords d. Variable can be of a fixed lengtharrow_forward8. Which of the following cannot be a variable? a. __init__ b. in c. it d. onarrow_forward
- Which of the following statements below is self-contradiction? a. [(X→Y) ∧ X]→Yb. [(~X→Y) ∧ (~X ∧ ~Y)]→Yc. X → (X ∨ Y)d. X ∧ (~X ∧ Y) 28arrow_forwardWhich of the following statements is correct? To raise the value of a variable, use increment; to reduce the value of a variable, use decrement. The word "system testing" should be defined.arrow_forwardWhich of the following are true? Ø ⊆ A, Ø ⊆ B, {0} ⊆ A, {0} ⊆ Barrow_forward
- Which of the following expressions is closest in value to 1? A) .09 B) 1.011 C) 99 ÷ 100 D) 100 ÷ 99arrow_forward48. Which of the following expressions results in an error? a. float(‘10’) b. int(‘10’) c. float(’10.8’) d. int(’10.8’)arrow_forward1.)Are the two expressions equal? (A+B)(A'+B+C')=( (B')(AC')' )'arrow_forward
- Which of the following expressions correctly tests if x is even?a) x % 2 == 0 b) even(x) c) not odd(x) d) x % 2 == xarrow_forwardState which of the following are true and which are false. If false, explain your answer.e) The following are all invalid variable names: 3g, 87, 67h2, h22, 2h.arrow_forwardQ2: Which of the following statements are equivalent? Which ones are correctly indented?arrow_forward
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning