Answer to Question #99427 in C++ for Caleb

Question #99427
Print the two strings in alphabetical order. Assume the strings are lowercase. End with newline. Sample output:
capes rabbits
#include <iostream>
#include <string>
using namespace std;

int main() {
string firstString;
string secondString;

cin >> firstString;
cin >> secondString;

/* Your solution goes here */

return 0;
}
1
Expert's answer
2019-12-03T08:27:41-0500

#include <iostream>

#include <string>

#include <windows.h>


using namespace std;


void printAlfabet(string first, string second);



int main()

{

  string firstString;

  string secondString;

  cin >> firstString;

  cin >> secondString;

  printAlfabet(firstString, secondString);

  return 0;

}



void printAlfabet(string first, string second)

{

  if(first[0] > second[0])

  {

    cout << second << " " << first;

  }

  else

    cout << first << " " << second;

}



Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS