Starting Out with C++: Early Objects
8th Edition
ISBN: 9780133360929
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: Addison-Wesley
expand_more
expand_more
format_list_bulleted
Question
Chapter 2.7, Problem 2.12CP
A) From the table 2-6:
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
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
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
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
17.
A function should determine the average of x and y.
What should be the function's parameters and return value(s)?
A.Parameters: none
Return values: X,y
B.Parameters: ×, y, average
Return value: none
C.Parameters: average
Return values; X, y
D.Parameters: X, y
Return value: average
Flowchart , code , output
10. Local variables are known only in the function in which they are defined.
Local variables are known only in the function in which they are defined.
True
O False
11. All types of functions can return more than one value.
All types of functions can return more than one value.
True
False
Chapter 2 Solutions
Starting Out with C++: Early Objects
Ch. 2.1 - The following C++ program will not compile because...Ch. 2.1 - On paper, write a program that will display your...Ch. 2.3 - Prob. 2.3CPCh. 2.3 - What output will the following lines of code...Ch. 2.3 - On paper, write a program that will display your...Ch. 2.5 - Which of the following are legal C++ assignment...Ch. 2.5 - List all the variables and literals that appear...Ch. 2.5 - When the above main function runs, what will...Ch. 2.5 - When the following main function runs, what will...Ch. 2.7 - Which of the following are illegal C++ variable...
Ch. 2.7 - Prob. 2.11CPCh. 2.7 - Prob. 2.12CPCh. 2.7 - Prob. 2.13CPCh. 2.7 - How would you combine the following variable...Ch. 2.7 - How would you combine the following variable...Ch. 2.8 - Prob. 2.16CPCh. 2.8 - What will the following code display? int number;...Ch. 2.8 - Prob. 2.18CPCh. 2.10 - Prob. 2.19CPCh. 2.10 - Which of the following is a character literal? 'B'...Ch. 2.10 - Prob. 2.21CPCh. 2.10 - What is wrong with the following program...Ch. 2.10 - Prob. 2.23CPCh. 2.10 - Write a program that stores your name, address,...Ch. 2.15 - Is the following assignment statement valid or...Ch. 2.15 - What is wrong with the following program? How...Ch. 2.15 - What will be assigned to x in each of the...Ch. 2.15 - Prob. 2.28CPCh. 2 - Every complete statement ends with a _____.Ch. 2 - To use cout statements you must include the _____...Ch. 2 - Every C++ program must have a function named...Ch. 2 - Prob. 4RQECh. 2 - A group of statements, such as the body of a...Ch. 2 - 'A', and "Hello World" are all examples of _____.Ch. 2 - 978.65 1012 would be written in E notation as...Ch. 2 - Prob. 8RQECh. 2 - Indicate if each of the following assignment...Ch. 2 - If the variables letter and w have been defined as...Ch. 2 - Indicate if each of the following cout statements...Ch. 2 - Indicate if each of the following cout statements...Ch. 2 - Assume integers x = 4, y = 7, and z = 2. What...Ch. 2 - Assume double variables x = 2.5, y = 7.0, and z =...Ch. 2 - Write a C++ statement that defines the double...Ch. 2 - Write a C++ statement that defines the int...Ch. 2 - Write assignment statements that perform the...Ch. 2 - Write assignment statements that perform the...Ch. 2 - Modify the following program segment so it prints...Ch. 2 - Rewrite the follow statement to use the newline...Ch. 2 - Create detailed pseudocode for a program that...Ch. 2 - Prob. 22RQECh. 2 - Prob. 23RQECh. 2 - Create detailed pseudocode for a program that...Ch. 2 - What will the following programs print on the...Ch. 2 - A) #include iostream using namespace std; int main...Ch. 2 - The following program contains many syntax errors....Ch. 2 - Soft Skills Programmers need good communication...Ch. 2 - Sum of Two Numbers Write a program that stores the...Ch. 2 - Prob. 2PCCh. 2 - Prob. 3PCCh. 2 - Restaurant Bill Write a program that computes the...Ch. 2 - Prob. 5PCCh. 2 - Prob. 6PCCh. 2 - Prob. 7PCCh. 2 - Prob. 8PCCh. 2 - Prob. 9PCCh. 2 - Prob. 10PCCh. 2 - Prob. 11PCCh. 2 - Prob. 12PCCh. 2 - Prob. 13PCCh. 2 - Prob. 14PCCh. 2 - Prob. 15PCCh. 2 - Prob. 16PCCh. 2 - Prob. 17PCCh. 2 - Prob. 18PC
Knowledge Booster
Similar questions
- What do you understand by local and global scope of variables? How can you access a global variable inside the function, if function has a variable with same name.arrow_forwardComplete the function movie_cost, which takes three parameters: age, permission and rating. age is an integer containing a person's age in years; permission is a Boolean that indicates whether a person has parental permission to see a particular move; and rating is one of G, PG, PG-13, or R. The function returns the cost of movie theater admission for the person according to the following rules, which are listed in order of decreasing precedence/priority: Nobody under the age of 10 may view an R-rated movie. • You must be 17 years old or have parental permission to view an R-rated movie. • You must be at least 13 years old or have parental permission to view a PG-13-rated movie. Prices: • Adult tickets (age greater than or equal to 16) are $15 each. • Child tickets (age less than 16) are $10 each. • If the person is not allowed to see the move, return o. Examples: Function Call movie_cost (17, False, 'R') movie_cost (16, True, 'R') movie_cost (12, True, 'R') Return Value 15 15 10…arrow_forwardWhich statement of the following is the most appropriate? Group of answer choices One good method for specifying what a function is supposed to do is to provide a precondition and postcondition for the function. One good method for specifying what a function is supposed to do is to provide a precondition and postcondition for the function. These form a contract between the programmer who uses the function and the programmer who writes the function. Using the assert function to check preconditions can significantly reduce debugging time, and the assertion-checking can later be turned off if program speed is a consideration. One good method for specifying what a function is supposed to do is to provide a precondition and postcondition for the function. These form a contract between the programmer who uses the function and the programmer who writes the function. Using the assert function to check preconditions can significantly reduce debugging time, and the…arrow_forward
- Select correct choice about functions? A) Each function should be written multiple times and it can be called once. B) Each function should be written once and it can be called multiple times. C) All of these choices. (D) Each function should be written once and it can be called once.arrow_forwardTrue/False 1. Programmers rarely define their own functionsarrow_forwardPlease complete the exercise as instructed and do not use global variables. Please follow the guidelines of what the solution cannot use provided in the second picture. Thank you!arrow_forward
- Define Named constant.arrow_forwardDefine a function named change_values that takes four integers as parameters and swaps or changes them based on a set of rules. Your Change Function should follow the following rules in the following order: 1. If the second value is an odd number, then it should be swapped with the first number. 2. If the third value is a power of two, then it should be swapped with the fourth value. 3. If the summation of the current values 1 to 3rd (after the above two rules are applied) is equal to the fourth value, then the fourth value should be set to the first value. Then write a Main program that reads four integers from standard input, calls function change_values() to swap the values, and prints the swapped values on a single line separated with spaces. Example Input: 1 3 4 0 Example Output: 3 1 0 3arrow_forwardProgramming Language: C++ 3. Which of the following are true for static variables but not for other variables? Select one or more: a. If they are defined and initialized on the same line, this line is guaranteed to only be executed once. b. They can only be used in the scope where they are defined. c. They can be used as arguments when calling a function d. They retain the value stored in them even after the function where they are defined returns e. They can be defined and initialized on the same line.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning