Question

Write in C++ Name sort Write a program that allows you to input up to 20...

Write in C++

Name sort

Write a program that allows you to input up to 20 names and sorts these names into alphabetic order and outputs them.

Write in C++

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>
#include <cstring>
using namespace std;

int main(){
int i,j,count;
char str[25][25],temp[25];
cout<<"How many strings u are going to enter?: ";
cin>>count;

cout<<"Enter Strings one by one: ";
for(i=0;i<=count;i++)
cin>>str[i];
for(i=0;i<=count;i++)
for(j=i+1;j<=count;j++){
if(strcmp(str[i],str[j])>0){
strcpy(temp,str[i]);
strcpy(str[i],str[j]);
strcpy(str[j],temp);
}
}
cout<<"\nOrder of Sorted Strings:";
for(i=0;i<=count;i++)
cout<<str[i]<<endl;

return 0;
}

Add a comment
Know the answer?
Add Answer to:
Write in C++ Name sort Write a program that allows you to input up to 20...
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 program that allows you to input multiple names and corresponding heights (assumed to be...

    Write a program that allows you to input multiple names and corresponding heights (assumed to be in inches). After the user has indicated that all names have been input, display the name of the tallest individual and their height. Sample run: "Name ?" James "Height?" 50 "Continue?" True "Name?" Sarah "Height?" 60 "Continue?" False "Sarah is the tallest at 60 inches"

  • Design a program that allows you to experiment with different sort algorithms in Java. This program should allow you to...

    Design a program that allows you to experiment with different sort algorithms in Java. This program should allow you to easily plug-in new sort algorithms and compare them. Assume that input data is generated randomly and stored in a text file (have no less than 2000 items to sort). Do not restrict your program to only one data type, or to one ordering relationship. The data type, ordering relationship, and the sorting method must be input parameters for your program....

  • 1. Write a program to input a list of names (strings) from the user and store...

    1. Write a program to input a list of names (strings) from the user and store them in an ArrayList. The input can be terminated by entering the empty string or by entering the string “quit”. 2. Add further functionality to your program so that it searches the ArrayList to find the first string and the last string according to dictionary ordering and then prints out these strings (names). Do this exercise without sorting the names in the ArrayList. For...

  • Design a program that allows the user to enter 5 names into a String array. Sort...

    Design a program that allows the user to enter 5 names into a String array. Sort the array in ascending (alphabetical) order and display its contents. Search the array for a specific name that the user wants. For this problem you will be submitting python homework, no flowchart

  • Write a program in C++ that prompts the user to input the name of a text...

    Write a program in C++ that prompts the user to input the name of a text file and then outputs the number of words in the file. You can consider a

  • Perform the following traces and submit your answer. Write the letters in your name as a...

    Perform the following traces and submit your answer. Write the letters in your name as a sequence without spaces (first name, middle name, last name). In my case the sequence is: CARLOSSILVA.submit a trace of how the 2 merge sorts algorithms will sort the letter in alphabetic order. In my example the sort result will be: AACILLORSSV . Be sure, that each step of the algorithm is clearly presented in the result table. a tracing for Down Merge Sort a...

  • 3. Name Search Modify the Sorted Names program that you wrote for exercises #2 so it...

    3. Name Search Modify the Sorted Names program that you wrote for exercises #2 so it allows you to search the array for a specific name. design a flowchart for it exercises 2 is as follow: Sorted Names Design a program that allows the user to enter 20 names into a String array. Sort the array in ascending (alphabetical) order and display its contents. Pseudocode for number 3 as follow: Initialize i=0 Get the name to search for If i<20...

  • Must be written in C++ Display results and comments Write a program that sorts a vector...

    Must be written in C++ Display results and comments Write a program that sorts a vector of names alphabetically using the selection sort and then searches the vector for a specific name using binary search. To do that, you need to write three functions: 1. void selSort (vector <string> & v): sorts the vector using selection sort 2. void display (const vector <string> & v): displays the vector contents 3. int binSearch (const vector <string> & v, string key): searches...

  • HI CAN YOU PLEASE PROGRAM THIS ASSIGNMENT USING C++ Ask the user to input a string. Then sort the string in reverse lex...

    HI CAN YOU PLEASE PROGRAM THIS ASSIGNMENT USING C++ Ask the user to input a string. Then sort the string in reverse lexicographic order and print it out. Reverse lexicographic means reverse alphabetic, e.g. zyxwvuts...edcba. This would be done using the integer values of the characters (ASCIl table). Use any one of the sorting methods we saw in class. For example: if the user enters "zeta" sorting it in reverse lexicographic order would give "ztea. if the user enters "ZETA"...

  • You will create a dimple Bubble Sort program to sort a string of random integers or...

    You will create a dimple Bubble Sort program to sort a string of random integers or text. Please read instructions and examples Please show screenshot of proof that the code works in the C program ECE 216 Programming Project 2 The Bubble Sort You will create a simple Bubble Sort program to sort a string of random integers or text or whatever you can punch in from the keyboard. For the input data, you will input a string of single...

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
ADVERTISEMENT