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 invalid variable name? a. -HCT b. SCT_ c. _HCT d. SCT
Which of the following is not a correct variable type? (a)  Float                 (b)  Real                  (c)  Int                     (d)  Double              (e)  Char.
Which of the following statements is correct? To raise the value of a variable, use increment; to reduce the value of a variable, use decrement.
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning