Instruction: Explain the functions of each code per line to get the desired result. #include using namespace std; void reversing(string& n){     int length =n.length();      int b = length-1;     int i = 0;     while(i<=b){         swap(n[i],n[b]);          b= b-1;          i= i+1;     } } int main(){     int count = 0;     string n = "";     cout<<"Enter strings: \t";     getline(cin,n);     reversing(n);     cout<<"String length: \t"<< n.length();     cout<<"\n";     cout<

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter14: Files And Streams
Section: Chapter Questions
Problem 16RQ
icon
Related questions
Question

Instruction: Explain the functions of each code per line to get the desired result.

#include <iostream>
using namespace std;

void reversing(string& n){

    int length =n.length(); 
    int b = length-1;
    int i = 0;

    while(i<=b){
        swap(n[i],n[b]); 
        b= b-1; 
        i= i+1;
    }
}

int main(){
    int count = 0;
    string n = "";

    cout<<"Enter strings: \t";
    getline(cin,n);
    reversing(n);
    cout<<"String length: \t"<< n.length();
    cout<<"\n";

    cout<<n;
    return 0;
}

 

Enter strings: Joseph Nathaniel Alambra
string length: 24
arbmalA leinahtaN hpesoj
Process exited after 10.84 seconds with return value 0
Press any key to continue
Transcribed Image Text:Enter strings: Joseph Nathaniel Alambra string length: 24 arbmalA leinahtaN hpesoj Process exited after 10.84 seconds with return value 0 Press any key to continue
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Computational Systems
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
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning