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?
- Python Question Which of the following is true of short-circuiting? a) It can be used for 'or', but not 'and'.b) It can be used for both 'and' and 'or'; its use depends on particular values.c) It is used on any Boolean expression; it doesn't matter what the values are.d) 'x or y' is always the same as 'y or x' because of short-circuiting.arrow_forwardIf the following code segment compiles correctly, what do you know about the variable x? if(x) WriteLine(OK); a. x is an integer variable. b. x is a Boolean variable. c. x is greater than 0. d. none of thesearrow_forwardWhat is the value of each of the following Boolean expressions? 54 3=3 2+45 6==7 2+4=6 3+4==4+3 1!=2 2!=2 5==72 3+9=0arrow_forward
- 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_forwardGive examples of valid variable names in SNOBOL IV. List the basic statements and briefly explain their operations.arrow_forwardIf you divide an integer by 11 what are the possible values of the remainder?arrow_forward
- Q2/ Complete the time expressions with for or since. half an hour a long time October last Tuesday a couple of weeks 2001 ten o'clock I was 14 three monthsarrow_forwardNo hand written and fast answer Details Explanationarrow_forward30. Which of the following is not a complex number? a. k = 2 + 3j b. k = complex(2, 3) c. k = 2 + 3l d. k = 2 + 3Jarrow_forward
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage