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<
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<
Chapter14: Files And Streams
Section: Chapter Questions
Problem 16RQ
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;
}
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 1 images
Knowledge Booster
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.Recommended textbooks for you
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning