Starting Out with C++: Early Objects (9th Edition)
9th Edition
ISBN: 9780134400242
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 2.10, Problem 2.21CP
Program Plan Intro
Byte occupation for a data type:
In
- There are many data types available in programming language.
- The basic data types are,
- char.
- int.
- float.
- double.
- bool.
- The memory byte for “char” datatype is “1”.
- The memory byte for “integer” data type is “2”.
- The memory byte for “float” data type is “4”.
- The memory byte for “double” data type is “8”.
- The memory byte for “bool” data type is “1”.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Complete this code using python language
#Write the conditions to check if anyone has won the game. This function will be called from the placeCharacter function. # r : In which row the current character was placed# c : In which column the current character was placed#returned value: True if anyone has won;Otherwise Flasedef checkBoard(r,c):#Write your code here #Write the necessary code to put the "char" in proper position of the board and check if anyone has won.#pos : The position that has been given by the player as input.#char : The character representing the player. It can be X or O.#count: It represents the number of turns. It can be from 0 to 8.#returned value: True if anyone has won;Otherwise Flasedef placeCharacter(pos,char,count):#Write your code heredef gameInitialization():global player1,player2player1 = input("Enter player 1's name:")player2 = input("Enter player 2's name:")print(f"{player1}, your character is X")print(f"{player2}, your character is O")def…
Given: Pseudo code
initialize char text
set text= z
print "%d", text
What will be the value of variable text?
122
98
97
O Error
def evalsum(s):
"""Returns a string encoding a sum expression as a value."""
evalsum: This function should accept a string encoding decimal numbers, separated by whitespace and by + and - operators, and should return None if invalid or the sum as a python float. For example, evalsum("1+2.2-3.141592") should return -0.5840800.... An input string-encoded number can be integral or not, can have preceding or trailing zeros or not, and can begin with a period, but cannot end with a period. Hint: try using re.match to match a prefix of the string in a loop, removing that prefix at each iteration.
Chapter 2 Solutions
Starting Out with C++: Early Objects (9th Edition)
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 - Sales Prediction The East Coast sales division of...Ch. 2 - Sales Tax Write a program that computes the total...Ch. 2 - Restaurant Bill Write a program that computes the...Ch. 2 - Miles per Gallon A car holds 16 gallons of...Ch. 2 - Distance per Tank of Gas A car with a 20 gallon...Ch. 2 - Number of Acres One acre of land is equivalent to...Ch. 2 - Land Calculation In the United States, land is...Ch. 2 - Circuit Board Price An electronics company makes...Ch. 2 - Prob. 10PCCh. 2 - Triangle Pattern Write a program that displays the...Ch. 2 - Diamond Pattern Write a program that displays the...Ch. 2 - Pay Period Gross Pay A particular employee earns...Ch. 2 - Basketball Player Height The star player of a high...Ch. 2 - Stock Loss Kathryn bought 750 shares of stock at a...Ch. 2 - Energy Drink Consumption A soft drink company...Ch. 2 - Past Ocean Levels The Earths ocean levels have...Ch. 2 - Future Ocean Levels During the past decade ocean...Ch. 2 - Annual High Temperatures The average July high...Ch. 2 - How Much Paint A particular brand of paint covers...
Knowledge Booster
Similar questions
- (Numerical) Using the srand() and rand() C++ library functions, fill an array of 1000 floating-point numbers with random numbers that have been scaled to the range 1 to 100. Then determine and display the number of random numbers having values between 1 and 50 and the number having values greater than 50. What do you expect the output counts to be?arrow_forwardWhat does this function using to? int max(int a , int b) if(a > b) return a; else return b; } returns the maximum of two integer numbers returns the minimum of two integer numbers returns the maximum of an floating point numbers returns the minimum of two floating point numbersarrow_forward| ZVY O = السؤال In C++ variable type char its size is: Three Bytes Two bytes One byte Non of them. حفظ الاجابةarrow_forward
- C programringarrow_forwardWhen using a printf() statement, what syntax do you use to print the value of a "char"? %s O%f %c %darrow_forwardVehicle Displacement You are given the velocity of shuttle traveling in a straight line as a series of data points. Write a program that computes the position (displacement) of the shuttle along this line at the time of the final data point The input is given vis standard input in the following format number of data points (0 < 65,535) on its own in • It pairs of data points, each on their own line, consisting of two integers separated by a ungle comma The first number represents the time in seconds (065535), and the second represents velocity in meters per second (4 v). Time is strictly increasing and velocity is constant between data points. The vehicle position and velocity both start at 0 May shuttles can drive in either direction, and in an added bit of realm the data points are speed-limited to about 25 mph in forward and 10 mph in reverse. However, in a reduced bit of realsm, the problem does imply that shuttles can change velocity instantaneously The output should be a single…arrow_forward
- 1. Which code segment results in "true" being returned if a number is even? Replace "MISSING CONDITION" with the correct code segment. function isEven(num){ if(MISSING CONDITION){ return true; } else { return false; } A. num % 2 == 0; В. num % 0 = 2; C. num % 1 - 0; D. num % 1 -m 2; O 000arrow_forwardIt is a graphical representation of an algorithm. * Program Code Flowchart Algorithm is the data type that can be used to declare one or more characters with stored required of 1bytes per character.* String Date Currency Numeric The three logical operators are False, And, True And, Not, If Or, Not, If And, Or, Not The value of Round (8.484) is: * 8.884 8.8 8 O O O O O O Oarrow_forwardQ5: In C programming, "Char" and "int" data types are used. They represent certain number of bits. Please fill in the blanks for following data types assuming that that the code is running on 32 bit machine. Data type Total number of bits/bytes int chararrow_forward
- Homework-1-Q 2021.pdf 4 من 5 Al-Farabi University College Computer Programming Methodology Department of Computer Engineering Dr. Hussein Muzahim Aziz Basi ylallt First Year 2020-2021 AL-FA RABI UNIVERS TY COLLIG Homework 3: Write a program to calculate two real numbers. The operation you are going to used are "add, subtract, multiple and division" and it is going to be optional to calculate the two numbers separately at each time you are going to execute the program, After you execute the program separately at each time your run the program the output look like below: • to add betveen tuo nunbers - to subtract bet veen tuo nunhers * to nultiply betveen tuo nunbera - to diu ide hetveen tuo nunbers Enter Enter Enter Enter Enter the operation i+ Enter the Ist nunher :2.3 Enter the 2nd nunber :5.6 The result is 7.980 Press any ke y to continue . • -- OR Enter Enter Enter Enter to add betveen tuo nunbers - to subtract betueen tuo nunbers - to nultiply betueen tuo nunbere to divide betueen…arrow_forwardThe following program has syntax errors. Correct them. On each successive line, assume that any preceding error has been corrected. (12) const char = STAR = '*' const int PRIME = 71; int main { int count, sum; double x; count = 1; sum = count + PRIME; x = 25.67 newNum = count * ONE + 2; sum + count = sum; (x + sum) ++; x = x + sum * COUNT; sum += 3 ; cout " count = " count ", sum = " sum ", PRIME = " Prime endl; }arrow_forwardWhat is the numeric value of each of the following expressions, as evaluated by the C# programming language? 2+5*3 9/4+10 10/3 2110 (51)*3 37/5 648 5+2*43*4 3*(2+5)/5 2852 19/2/2 28/(2+4)arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning