STARTING OUT WITH C++ MPL
STARTING OUT WITH C++ MPL
9th Edition
ISBN: 9780136673989
Author: GADDIS
Publisher: PEARSON
bartleby

Concept explainers

Question
Book Icon
Chapter 3, Problem 1RQE

A)

Program Plan Intro

String object:

  • The variable “char” is used to hold only the characters but the variable string is to hold the whole set of character.
  • Thus, string object is used to carry set of characters and it is declared with the keyword “string” followed by the object name.

A)

Expert Solution
Check Mark

Explanation of Solution

“cin” statement to read a one word string:

When a string input is read using “cin” with a “>>” operator then the “cin” reads the data passed over it and it removes the whitespace characters such as spaces, tabs and line breaks in the string.

  • Once it reaches the first non-blank character then it starts reading and it stops the reading process until it reaches the next whitespace character.

“cin” statement that reads a string in one word is as follows:

  //get value of the description as a one word string

  cin >> description;

  • The above statement is used to read the input string until it receives the whitespace and then it ignores the remaining part of the string.

Therefore, “cin >> description;” is the “cin” statement which reads a string as one word string.

B)

Program Plan Intro

String object:

  • The variable “char” is used to hold only the characters but the variable string is to hold the whole set of character.
  • Thus, string object is used to carry set of characters and it is declared with the keyword “string” followed by the object name.

B)

Expert Solution
Check Mark

Explanation of Solution

“cin” statement to read multiple words:

In C++, using the “cin” statement, the multiple words can be read through the function getline().

  • This getline() function read the line from the user including both leading and embedded spaces and then stores that line into the string object.

“cin” statement that reads multiple words in a string is as follows:

/* Read a string which contains multiple words separated by blanks */

  getline(cin, description);

The above line is used to get input from the user by using “getline()”; the input contains multiple words which are separated by space.

Therefore, “getline(cin, description);” is the input statement that reads multiple words in a string using the getline() function.

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
python programing:  You are going to create a race class, and inside that class it has a list of entrants to the race.   You are going to create the daily schedule of three or so races and populate the races with the jockey/horse entries and then print out the schedule.   Create a race class that has   The name of the race as a character string, ie “RACE 1” or “RACE 2”,  The time of the race A list of entries for that race   Create a list of of 3 (or 4) of those race objects(races) for the day   For the list of entries for a particular race, make a entrant class (the building block of your entrants list) you should have   The horse name The jockey name   Now you need to   Populate the structure (ie set up three races on the schedule, add 2-3 horses entries to each race.  You can hardcode the entries if you want to, rather than getting them from the user, just to save the time of making a menu interface and whatnot. Be able to print the days schedule   So example output would be…
Q5: Declare a data structure student t for the record of a student as follows: string name //the name of the student int class //1,2,3,4 char group //a,b, c,d,. string subject // e.g. computer programming 3 marks_t notes // the notes of this subject
True or false: When an object is passed to a function, but the function is not supposed to change it, it is best to pass it by value.

Chapter 3 Solutions

STARTING OUT WITH C++ MPL

Ch. 3.2 - Prob. 3.11CPCh. 3.2 - Study the following program code and then complete...Ch. 3.2 - Complete the following program skeleton so that it...Ch. 3.3 - Assume the following variable definitions: int a =...Ch. 3.3 - What will the following program code display if a...Ch. 3.3 - What will the following program code display? int...Ch. 3.5 - Prob. 3.17CPCh. 3.5 - Complete the following program code segment so...Ch. 3.6 - Write a multiple assignment statement that assigns...Ch. 3.6 - Write statements using combined assignment...Ch. 3.6 - What will the following program segment display?...Ch. 3.7 - Write cout statements with stream manipulators...Ch. 3.7 - The following program segment converts an angle in...Ch. 3.8 - Will the following string literal fit in the space...Ch. 3.8 - If a program contains the definition string name;...Ch. 3.8 - Prob. 3.26CPCh. 3.10 - Use a mathematical library function with a cout...Ch. 3.10 - Assume the variables angle1 and angle2 hold angles...Ch. 3.10 - To find the cube root (the third root) of a...Ch. 3.10 - Write a statement that produces a random number...Ch. 3 - Prob. 1RQECh. 3 - Prob. 2RQECh. 3 - Prob. 3RQECh. 3 - Assume the following variables are defined: int...Ch. 3 - What header files must be included in the...Ch. 3 - Prob. 6RQECh. 3 - Prob. 7RQECh. 3 - Complete the following table. Expression Value of...Ch. 3 - Write C++ expressions for the following algebraic...Ch. 3 - Assume a program has the following variable...Ch. 3 - Prob. 11RQECh. 3 - Assume that qty and salesReps are both integers....Ch. 3 - Rewrite the following variable definition so the...Ch. 3 - Complete the following table by writing statements...Ch. 3 - Write a multiple assignment statement that can be...Ch. 3 - Write a pair of multiple assignment statements...Ch. 3 - Replace the following statements with a single...Ch. 3 - Is the following code legal? Why or why not? const...Ch. 3 - Write a cout statement that uses stream...Ch. 3 - Write a cout statement that uses stream...Ch. 3 - What header file must be included A) to perform...Ch. 3 - Pet World offers a 15 percent discount to senior...Ch. 3 - A bowling alley is offering a prize to the bowler...Ch. 3 - A retail store grants its customers a maximum...Ch. 3 - Little Italy Pizza charges 14.95 for a 12-inch...Ch. 3 - Trace the following program segments and tell what...Ch. 3 - A) (Assume the user enters George Washington.)...Ch. 3 - Each of the following program segments has some...Ch. 3 - A) const int number1, number2, product; cout ...Ch. 3 - Soft Skills Often programmers work in teams with...Ch. 3 - Miles per Gallon Write a program that calculates a...Ch. 3 - Stadium Seating There are three searing categories...Ch. 3 - Housing Costs Write a program that asks the user...Ch. 3 - How Much Insurance? Many financial experts advise...Ch. 3 - Batting Average Write a program to find a baseball...Ch. 3 - Test Average Write a program that asks for five...Ch. 3 - Average Rainfall Write a program that calculates...Ch. 3 - Male and Female Percentages Write a program that...Ch. 3 - Vacation Days Write a program that prompts the...Ch. 3 - Box Office A movie theater only keeps 80 percent...Ch. 3 - How Many Widgets? The Yukon Widget Company...Ch. 3 - How many Calories? A bag of cookies holds 30...Ch. 3 - Ingredients Adjuster A cookie recipe calls for the...Ch. 3 - Celsius to Fahrenheit Write a program that...Ch. 3 - Currency Write a program that will convert U.S....Ch. 3 - Monthly Sales Tax A retail company muse file a...Ch. 3 - Property Tax Madison County collects property...Ch. 3 - Senior Citizen Property Tax Madison County...Ch. 3 - Math Tutor Write a program that can be used as a...Ch. 3 - Interest Earned Assuming there are no deposits...Ch. 3 - Monthly Payments The monthly payment on a loan may...Ch. 3 - Pizza Slices Joe's Pizza Palace needs a program to...Ch. 3 - How Many Pizzas? Modify the program you wrote in...Ch. 3 - Angle Calculator Write a program that asks the...Ch. 3 - Stock Transaction Program Last month Joe purchased...
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
  • Text book image
    EBK JAVA PROGRAMMING
    Computer Science
    ISBN:9781337671385
    Author:FARRELL
    Publisher:CENGAGE LEARNING - CONSIGNMENT
    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
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,