Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include #include using namespace std; int flipfirst ( string& first _ name, string& last _ name ) { if ( first _ name.empty ( )

#include
#include
using namespace std;
int flipfirst(string& first_name, string& last_name){
if (first_name.empty()|| last_name.empty()){
return 0;
}
char original_last_first_letter = last_name[0]; // Store the original first letter of the last name
first_name[0]= last_name[0];
last_name[0]= original_last_first_letter; // Assign the original first letter of the last name
return 1;
}
int main(){
string first_name, last_name;
cout << "Enter your first name: ";
getline(cin, first_name);
cout << "Enter your last name: ";
getline(cin, last_name);
int result = flipfirst(first_name, last_name);
if (result ==1){
cout << "After flipping the first letters: "<< first_name <<""<< last_name << endl;
}
else {
cout << "One or both of the names are empty." << endl;
}
return 0;
}
Help fix output
Enter your first name: Ashley
Enter your last name: Castro
After flipping the first letters: Cshley Castro

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional SQL Server 2000 Database Design

Authors: Louis Davidson

1st Edition

1861004761, 978-1861004765

More Books

Students also viewed these Databases questions

Question

Explain the service recovery paradox.

Answered: 1 week ago