C++ How To Program (Early Objects Version), Global Edition, With Access Card, 10 Ed
10th Edition
ISBN: 9780134448848
Author: Paul Deitel, Harvey Deitel
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 21, Problem 21.8E
Program Plan Intro
Use of rbegin() and rend()
- Include the required header files.
- Define the “main()” function
- Create a string variable str with value “Hello World”.
- Display the original value of str variable.
- Display the message “String in reverse order”.
- Create a reverse_iterator rit.
- Using a loop, traverse it from the end of the string to the beginning of the string using the rbegin() and rend() functions.
- Display each character of the string.
Program:
The following program demonstrates the importance of the functions rbegin() and rend() in the traversal of strings.
/*Include required header files*/ #include <iostream> #include <string> using namespace std;
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
What’s the output of the following programs?
What is the output from the following statement?
-Convert SES variable to a factor and assign the value labels “low”, ”middle” and “high” to the 3 levels of thevariable.
Then
-Define the variables complic, comorb, depressi, diabetes as factors. For all these factors, a zero means “no” and a 1 means “yes”. Assign these value labels through the function factor() and check the change using str()
Chapter 21 Solutions
C++ How To Program (Early Objects Version), Global Edition, With Access Card, 10 Ed
Ch. 21 - Prob. 21.4ECh. 21 - Prob. 21.5ECh. 21 - (Find Code Error) Find any errors in the following...Ch. 21 - (Simple Encryption) Some information on the...Ch. 21 - Prob. 21.8ECh. 21 - Prob. 21.9ECh. 21 - (String Concatenation) Write a program that...Ch. 21 - (Hangman Game) Write a program that plays the game...Ch. 21 - (Printing a string Backward) Write a program that...Ch. 21 - (Alphabetizing Animal Names) Write a program that...
Ch. 21 - Prob. 21.14ECh. 21 - Prob. 21.15ECh. 21 - Prob. 21.16ECh. 21 - Prob. 21.17ECh. 21 - Prob. 21.18ECh. 21 - (Erasing Characters from a string) Write a program...Ch. 21 - Prob. 21.20ECh. 21 - Prob. 21.21ECh. 21 - Prob. 21.22ECh. 21 - Prob. 21.23ECh. 21 - Prob. 21.24ECh. 21 - Prob. 21.25ECh. 21 - (Cooking with Healthier Ingredients) Obesity in...Ch. 21 - Prob. 21.27MADCh. 21 - (SMS Language) Short Message Service (SMS) is a...
Knowledge Booster
Similar questions
- State whether each of the following is true or false. If false, explain why h) All arguments following the format control string in a printf function must be preceded by an ampersand (&).arrow_forwardFind the error in each of the following programing ?arrow_forwardWhat is the output from each of the following pseudocode statements?arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- C++ 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
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