Here is a tutorial that uses the Xcode IDE on a Mac laptop to create a C++ desktop compiled application using a Bubble Sort method to numerically sort some numbers (ie. double).
Attempting to write code with a generic eye has the advantage that you end up with more flexibility, and, usually, more readable code.
Some ideas used in today’s code include:
- The use of Preprocessor directives via #define identifier replacement syntax … will fit in with all those lovers of interpretive languages
- The use of Command line arguments as with ./Test 22 2 15 0 … adds to the flexibility of your code with the user being able to tailor each usage of the executable
- The use of a pointer to an array within a function, meaning that the data can be changed (ie. sorted) in situ rather than returning a value (or resorting to a global variable array) … hence we use void numerically_sort_array(double* asort, int isize = ASIZE, bool ascending = (SMODE != 0)) … you could change the void return, to return an error code, for example
- The C++ use of default values in parameters of the function call, making use of the Preprocessor directives, so that the call could make sense as numerically_sort_array(psarray); as numerically_sort_array(psarray, 1000, true); … such thoughts come into play, in C++, also when considering Overloading
- The deliberate pointing out of any important restriction should there be one … doh! … in that we have a stipulation for a double data type array … and have not implemented any Template functionality, on this occasion
Link to some downloadable C++ programming code … rename to main.cpp for use.
If this was interesting you may be interested in this too.



Revisiting your Worldwide Country Quiz so that the Geo Chart still draws a map even for a small country such as Andorra, and adding Wikipedia images after an answer, keeps the focus on a working world-country quiz rather than only on the surrounding code. I work on World Geography; our world map quiz is a free, untimed browser option for adults and does not need an account. It is another practice link, not a programming tutorial and not a replacement for the Worldwide Country Quiz you are building here.