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 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.
use python language only, no c++ or other
Why is it important to avoid using 'magic numbers' directly in code and instead use constants?
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
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage