Starting Out with C++ from Control Structures to Objects (9th Edition)
Starting Out with C++ from Control Structures to Objects (9th Edition)
9th Edition
ISBN: 9780134498379
Author: Tony Gaddis
Publisher: PEARSON
Question
Book Icon
Chapter 2.6, Problem 2.9CP
  1. A)
Program Plan Intro

Data types:

The variables use data-type during their declaration.

  • The data-type is used to determine the size of memory allocated. Here, the compiler allots the memory.
  • All data-type needs different size of memory.

Some of the data-types are:

  • Integer
  • Boolean
  • Character
  • Double
  • Floating point

From the table 2-6:

Variable to hold numbers in the range from 32 to 6,000

From the table 2-6, “short” or “unsigned short” data-type hold numbers in the range from 32 to 6,000.

  1. B)
Program Plan Intro

Data types:

The variables use data-type during their declaration.

  • The data-type is used to determine the size of memory allocated. Here, the compiler allots the memory.
  • All data-type needs different size of memory.

Some of the data-types are:

  • Integer
  • Boolean
  • Character
  • Double
  • Floating point

From the table 2-6:

Variable to hold numbers in the range from 240,000 to 140,000

From the table 2-6, “int” data-type hold numbers in the range from 240,000 to 140,000.

  1. C)
Program Plan Intro

Data types:

The variables use data-type during their declaration.

  • The data-type is used to determine the size of memory allocated. Here, the compiler allots the memory.
  • All data-type needs different size of memory.

Some of the data-types are:

  • Integer
  • Boolean
  • Character
  • Double
  • Floating point

From the table 2-6:

Literal which uses more memory

From the given literal “20” and “20L”; both the literals uses same amount of memory because both the “int” and “long int” data-types size are 4 bytes.

Blurred answer
Students have asked these similar questions
Refer to the data types listed in Table 2-6 for these questions.A) If a variable needs to hold numbers in the range 32 to 6,000, what data typewould be best?B) If a variable needs to hold numbers in the range 40,000 to 40,000, whatdata type would be best?C) Which of the following literals uses more memory? 20 or 20L
Question 1 You have to define the data type declaration for a variable that will store a string of text of 100 characters. You will be referencing the variable as a string and not as a series of individual characters. Assume the variable is called strText. What is the data definition for the variable?
C1. Write an assignment that assigns to a variable named red_change the percentage change in the red level if red were updated to be 128. (Hint: use floating point division) C2. Write an assignment that assigns a variable named new_blue so that it contains the blue value (as a float), assuming the new_blue value is equivalent to blue increased by 25 percent.

Chapter 2 Solutions

Starting Out with C++ from Control Structures to Objects (9th Edition)

Ch. 2.8 - Prob. 2.11CPCh. 2.8 - Which of the following is a character literal? B BCh. 2.8 - Prob. 2.13CPCh. 2.8 - Write a program that has the following character...Ch. 2.8 - What is wrong with the following program...Ch. 2.8 - Prob. 2.16CPCh. 2.8 - Write a program that stores your name, address,...Ch. 2.11 - Prob. 2.18CPCh. 2.11 - Prob. 2.19CPCh. 2.11 - Prob. 2.20CPCh. 2.14 - Is the following assignment statement valid or...Ch. 2.14 - How would you consolidate the following...Ch. 2.14 - What is wrong with the following program? How...Ch. 2.14 - Prob. 2.24CPCh. 2.16 - Prob. 2.25CPCh. 2 - How many operands does each of the following types...Ch. 2 - How may the double variables temp, weight, and age...Ch. 2 - Prob. 3RQECh. 2 - Write assignment statements that perform the...Ch. 2 - Is the following comment written using single-line...Ch. 2 - Is the following comment written using single-line...Ch. 2 - Modify the following program so it prints two...Ch. 2 - What will the following programs print on the...Ch. 2 - Multiple Choice 9. Every complete statement ends...Ch. 2 - Prob. 10RQECh. 2 - Every C++ program must have a ________. A) cout...Ch. 2 - Preprocessor directives begin with ________. A) #...Ch. 2 - The following data 72 'A' Hello World" 2.8712 are...Ch. 2 - A group of statements, such as the contents of a...Ch. 2 - Which of the following are not valid assignment...Ch. 2 - Which of the following are not valid cout...Ch. 2 - Assume w = 5, x = 4, y = 8, and z = 2. What value...Ch. 2 - How would each of the following numbers be...Ch. 2 - The negation operator is ________. A) unary B)...Ch. 2 - A(n) ___________ is like a variable, but its value...Ch. 2 - Prob. 21RQECh. 2 - T F A variable must be defined before it can be...Ch. 2 - T F Variable names may begin with a number.Ch. 2 - T F Variable names may be up to 31 characters...Ch. 2 - T F A left brace in a C++ program should always be...Ch. 2 - T F You cannot initialize a named constant that is...Ch. 2 - Prob. 27RQECh. 2 - Convert the following pseudocode to C++ code. Be...Ch. 2 - There are a number of syntax errors in the...Ch. 2 - Sum of Two Numbers Write a program that stores the...Ch. 2 - Sales Prediction The East Coast sales division of...Ch. 2 - Sales Tax Write a program that will compute the...Ch. 2 - Restaurant Bill Write a program that computes the...Ch. 2 - Average of Values To get the average of a series...Ch. 2 - Annual Pay Suppose an employee gets paid every two...Ch. 2 - Ocean Levels Assuming the oceans level is...Ch. 2 - Total Purchase A customer in a store is purchasing...Ch. 2 - Cyborg Data Type Sizes You have been given a job...Ch. 2 - Miles per Gallon A car holds 15 gallons of...Ch. 2 - Distance per Tank of Gas A car with a 20-gallon...Ch. 2 - Land Calculation One acre of land is equivalent to...Ch. 2 - Circuit Board Price An electronics company sells...Ch. 2 - Prob. 14PCCh. 2 - Triangle Pattern Write a program that displays the...Ch. 2 - Diamond Pattern Write a program that displays the...Ch. 2 - Stock Commission Kathryn bought 750 shares of...Ch. 2 - Energy Drink Consumption A soft drink company...Ch. 2 - Annual High Temperatures The average July high...Ch. 2 - How Much Paint A particular brand of paint covers...
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning