C++ How To Program (Early Objects Version), Global Edition, With Access Card, 10 Ed
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
Question
Book Icon
Chapter 21, Problem 21.8E
Program Plan Intro

Use of rbegin() and rend()

Program Plan:

  • 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;

Blurred answer
Students 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()
Knowledge Booster
Background pattern image
Recommended textbooks for you
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning