Hello everyone. I have a few questions about this project that I need to code. And If you can please show me how the code should look I would very much appreciate it.

Write a program that can sort integers, decimals, and characters from ascending and descending orders.

The program has to use the following C++ features:
- Take input from user
- Use different data types
- Use if statement
- Use while or for loops
- Use arrays
- Define and call functions
- Pass array or pointers to function
- Use function overloading
- Present output to the screen

Now, for the different types like integers, decimals and characters, do I write a separate code for each one in ascending and descending order? Or do I need to incorporate all of them together?

Thank you for all of your help!

Recommended Answers

All 3 Replies

Well you need to write a sort fuinction that will take an int array and sort in asscending order. You will need to repet this for decimal types and char types. Then you have to write the same sort function but change them from asecending to decending order. This will cover most of your requierments since you will overload the functions for the different types.

Can you please give me head start as to how I would set up the int array in ascending order? After that, I can understand how the other parts will need to be done. Thanks so much Nathan.

Here's the buble-sort algorithm explained: Click Here
Try to think now how to apply this algorithm to work for strings and other items.
Also, have a look at the STL sort algorithm: Click Here

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.