Question

Write a C++ program that asks the user to enter first lettters of the names of...

Write a C++ program that asks the user to enter first lettters of the names of his two favourite persons. The program should print which persons name comes first alphabetically.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include <iostream>
using namespace std;
int main() {
  string name1,name2;
  cout<<"Enter name1: ";
  cin>>name1;
  
  cout<<"Enter name2: ";
  cin>>name2;
  
  if(name1<name2){
   cout<<name1<<endl;
   cout<<name2<<endl;
  }
  else{
   cout<<name2<<endl;
   cout<<name1<<endl;
  }
  return 0;
}

Add a comment
Know the answer?
Add Answer to:
Write a C++ program that asks the user to enter first lettters of the names of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a C program which asks the user to enter a name of a person and...

    Write a C program which asks the user to enter a name of a person and the program finds the number of that person. The number is displayed. Otherwise output "Not found". Your program have to check only given names. The program declares and initializes a two-dimensional array of characters that holds pairs of names and numbers. The array can hold 10 strings, each capable of holding up to 79 characters. Array elements are following: "Adam", "585-5622", "Mark", "505-8446", "Austin",...

  • Write a program that prompts the user to enter a list of names. Each person's name...

    Write a program that prompts the user to enter a list of names. Each person's name is separated from the next by a semi-colon and a space (: and the names are entered lastName, firstName (i.e. separated by ',). Your program should then print out the names, one per line, with the first names first followed by the last names. A sample run of your program should look like Please enter your list of names: Epstein, Susan; St. John, Katherine;...

  • Create a Java program which asks the user how many names they want to enter. The...

    Create a Java program which asks the user how many names they want to enter. The program should then instantiate an array that will hold this many names. The main method should call a method, getNames() to allow the user to enter the names. A for loop should be used in this method. Once the names are entered, the main method should call another method displayNames() which will use a while loop to display the names entered.

  • Write a program that asks the user to enter a string and then asks the user...

    Write a program that asks the user to enter a string and then asks the user to enter a character. The program should count and display the number of times that the specified character appears in the string. python programming

  • write a program that asks the user to enter two integers one at a time if...

    write a program that asks the user to enter two integers one at a time if the first value is not an integer then do not ask for a second then display both values otherwise print error message stating which value entered was not an integer python

  • In C Write a function that asks for the user's first, middle, and last names. The...

    In C Write a function that asks for the user's first, middle, and last names. The names will be entered by the user on a single line and will be stored in three different C-strings. The program should then store, in a fourth array, the name arranged in the following manner: the last name followed by a comma and a space, followed by the first name and a space, followed by the middle name. For example, if the user entered...

  • I need Pseudocode Algorithm only, please Write a program that asks the user to enter the...

    I need Pseudocode Algorithm only, please Write a program that asks the user to enter the name of his or her favorite city. use a String variable to store the input. The program should display the following: The number of characters in the city name the name of the city in all uppercase letters the name of the city in all lower case letters the first character in the name of the city

  • ***** JAVA ONLY ***** Write a program that asks the user to enter the name of...

    ***** JAVA ONLY ***** Write a program that asks the user to enter the name of a file, and then asks the user to enter a character. The program should count and display the number of times that the specified character appears in the file. Use Notepad to create a simple file that can be used to test the program. ***** JAVA ONLY *****

  • Write a program which asks the user to enter an integer. Use switch statement to write...

    Write a program which asks the user to enter an integer. Use switch statement to write out the numeric word (such as ONE) if the user's input is 1; (see the sample run output for the usr input 2 or 3); otherwise, write OUT OF RANGE. Below are few sample runs: If the user enters a 1, the program will print: ONE TWO THREE Or, if the user enters a 2, the program will print: TWO THREE Or, if the...

  • Write a java program that asks the user to enter an integer. The program should then...

    Write a java program that asks the user to enter an integer. The program should then print all squares less than the number entered by the user. For example, if the user enters 120, the program should display 0, 1, 4, 9, 16, 25, 36, 49, 64, 81, and 100.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT