Programming in C
Programming in C
4th Edition
ISBN: 9780321776419
Author: Stephen G. Kochan
Publisher: Addison-Wesley
Question
Book Icon
Chapter 3, Problem 2E
Program Plan Intro

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.

Expert Solution & Answer
Check Mark

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?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
Which 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 length
Which of the following is a convention in Mathematics? a. Sets b. Fractals c. Digits 0 to 9
Select 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.
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage