Starting Out With C++: Early Objects (10th Edition)
10th Edition
ISBN: 9780135235003
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
The following program or program segment has errors. Find as many as you can.
char numeric[5];
int x = 123;
numeric = atoi(x);
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…
function avg and pass x and y
Tin
printf ("the avg of x and y is %d\n', avgl)
give_sqrt (avgl);
return 0,
float avg (float m, float n)
I/ Return the average of n and m
void give sqrt (float x)
printf ('the sqrt of is Mn'x
:/ Print the sqrt value of x.
return;
Chapter 2 Solutions
Starting Out With C++: Early Objects (10th 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 - 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. 24RQECh. 2 - Prob. 25RQECh. 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 - 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 - 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_forwardCLEAR MY CHOICE The following code segment is supposed to read all of the integers entered by the user until a blank line is entered and store them in values values = [ ] inputStr = input ("Enter a value (blank line to quit): ") values.append (int (inputStr)) inputStr = input ("Enter a value (blank line to quit): ") What line of code should be placed in the blank to achieve this goal? Select one: while inputStr in values : for ch in inputStr : for values in inputStr : while inputStr !- "" on people = ["John", "Rob", "Bob"]arrow_forwardRefer to the following code. Which line may be used to complete the code so it would not result to an error? count = 15 while count > 5: print (count) A none of these; the code is complete by itself (B) count == count (C) count = count - 4 (D) count += 1arrow_forward
- d) Print NATURAL numbers from 5 to 25 without using a single digit in the code. Note: Use knowledge of chars in this. Java languagearrow_forwarddef 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.arrow_forwardchar b = A'; System.out.printin(b % 2); displays an error occurs because a value of type char is not numeric Deither 1 or 0 the character A is displayedarrow_forward
- Q1: complete the function that will return the multipication of 3 given numbers - a,b,c. In [ ]: def multiply_numbers(a,b,c): II II || """insert the code that performs the operation. Use the variable 'number' to hold and return the value II || || # your code here return numberarrow_forwardC programringarrow_forwardWhen using a printf() statement, what syntax do you use to print the value of a "char"? %s O%f %c %darrow_forward
- Use Pointer Write a program that allows the user to enter the last names of a number of candidates in a local election and the number of votes received by each candidate. The program should then output each candidate's name, the number of votes received, and the percentage of the total votes received by the candidate. Your program should also output the winner of the election. A sample output is: Number of Candidates: 5 Candidate Votes recieve %of total vote Johnson 5000 25.91 Miller 4000 20.73 Duffy 6000 31.09 Robinson 2500 12.95 Ashtony 1800 9.33 Total 19300 The winner of the election is Duffy!!arrow_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_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
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