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
What are the major threats of using the internet? How do you use it? How do children use it? How canwe secure it? Provide four references with your answer. Two of the refernces can be from an article and the other two from websites.
Assume that a string of name & surname is saved in S. The alphabetical characters in S can be in lowercase and/or uppercase letters. Name and surname are assumed to be separated by a space character and the string ends with a full stop "." character. Write an assembly language program that will copy the name to NAME in lowercase and the surname to SNAME in uppercase letters. Assume that name and/or surname cannot exceed 20 characters. The program should be general and work with every possible string with name & surname. However, you can consider the data segment definition given below in your program. .DATA S DB 'Mahmoud Obaid." NAME DB 20 DUP(?) SNAME DB 20 DUP(?) Hint: Uppercase characters are ordered between 'A' (41H) and 'Z' (5AH) and lowercase characters are ordered between 'a' (61H) and 'z' (7AH) in the in the ASCII Code table. For lowercase letters, bit 5 (d5) of the ASCII code is 1 where for uppercase letters it is 0. For example, Letter 'h' Binary ASCII 01101000 68H 'H'…
What did you find most interesting or surprising about the scientist Lavoiser?
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
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
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning