Ask your own question, for FREE!
Computer Science 16 Online
OpenStudy (anonymous):

how to make a program in c++[using Array] that ask the user to input 9 letters and arrange it in alphabetical order. thanks!

OpenStudy (anonymous):

#include <iostream> #include <string> using namespace std; int main() { string str = ""; cout << "input : "; cin >> str; { for(int i = 0; i < str.size(); i++) { for(int j = i + 1; j < str.size(); j++) { if(str[i] > str[j]) { char temp = str[i]; str[i] = str[j]; str[j] = temp; } } } cout << "output: " << str << "\n"; } }

OpenStudy (across):

Here's an implementation that's more specific (it uses an array of characters, not a string object): http://ideone.com/LqqJgD

OpenStudy (anonymous):

when i tried your program the output is equal to the imputed char. the program should arranged the imputed char in to alphabetical order.??

OpenStudy (across):

Whose program?

OpenStudy (anonymous):

The code you posted. when i started debugging it works fine. but when i started imputing letters the output didn't satisfies the problem. it did not arrange the imputed letters into alphabetical order. it only prints the first char imputed.i don't know what's wrong with it.

OpenStudy (across):

The code is working correctly with the Ideone compiler. Perhaps your input is incorrect?

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!