{"id":10679,"date":"2014-11-20T05:06:42","date_gmt":"2014-11-19T18:06:42","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=10679"},"modified":"2015-07-21T07:03:01","modified_gmt":"2015-07-20T21:03:01","slug":"c-xcode-numerical-bubble-sort-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/c-xcode-numerical-bubble-sort-tutorial\/","title":{"rendered":"C++ Xcode Numerical Bubble Sort Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/CPlusPlus\/sort\/CPlusPlus_sort.png\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"C++ Xcode Numerical Bubble Sort Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/CPlusPlus\/sort\/CPlusPlus_sort.png\" title=\"C++ Xcode Numerical Bubble Sort Tutorial\"  id=\"qtoijximpept\" onmouseover=\" this.src=this.src.replace('.jpg','.JPEG').replace('.png','.jpg').replace('.gif','.png').replace('.jpeg','.gif').replace('.JPEG','.jpeg'); \"  \/><\/a><p class=\"wp-caption-text\">C++ Xcode Numerical Bubble Sort Tutorial<\/p><\/div>\n<p>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. <i>double<\/i>).<\/p>\n<p>Attempting to write code with a generic eye has the advantage that you end up with more flexibility, and, usually, more readable code.<\/p>\n<p>Some ideas used in today&#8217;s code include:<\/p>\n<ul>\n<li>The use of <a target=_blank title='Preprocessor directives' href='http:\/\/www.cplusplus.com\/doc\/tutorial\/preprocessor\/'>Preprocessor directives<\/a> via <i>#define identifier replacement<\/i> syntax &#8230; will fit in with all those lovers of interpretive languages<\/li>\n<li>The use of <a target=_blank title='Command line arguments' href='http:\/\/www.cplusplus.com\/forum\/beginner\/5404\/'>Command line arguments<\/a> as with <i>.\/Test 22 2 15 0<\/i> &#8230; adds to the flexibility of your code with the user being able to tailor each usage of the executable<\/li>\n<li>The use of a <a target=_blank title='Pointer' href='http:\/\/www.cplusplus.com\/doc\/tutorial\/pointers\/'>pointer<\/a> 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) &#8230; hence we use <i>void numerically_sort_array(double* asort, int isize = ASIZE, bool ascending = (SMODE != 0))<\/i> &#8230; you could change the <i>void<\/i> return, to return an error code, for example<\/li>\n<li>The C++ use of <a target=_blank title='Function default values' href='http:\/\/www.cplusplus.com\/doc\/tutorial\/functions\/#defaultvalues'>default values in parameters<\/a> of the function call, making use of the Preprocessor directives, so that the call could make sense as <i>numerically_sort_array(psarray);<\/i> as <i>numerically_sort_array(psarray, 1000, true);<\/i> &#8230; such thoughts come into play, in C++, also when considering <a target=_blank title='Overloading and templates' href='http:\/\/www.cplusplus.com\/doc\/tutorial\/functions2\/'>Overloading<\/a><\/li>\n<li>The deliberate pointing out of any important restriction should there be one &#8230; doh! &#8230; in that we have a stipulation for a <a target=_blank title='C++ basic data type' href='http:\/\/www.cplusplus.com\/doc\/tutorial\/variables\/#fundamental'><i>double<\/i><\/a> data type array &#8230; and have not implemented any  <a target=_blank title='Overloading and templates' href='http:\/\/www.cplusplus.com\/doc\/tutorial\/functions2\/'>Template<\/a> functionality, on this occasion<\/li>\n<\/ul>\n<p>Link to some downloadable C++ programming code &#8230; rename to <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/CPlusPlus\/sort\/main.cpp_GETME' title='Download me'>main.cpp<\/a> for use.<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d10679' onclick='var dv=document.getElementById(\"d10679\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?s=C%2B%2B\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d10679' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>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 &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/c-xcode-numerical-bubble-sort-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,29,37,40],"tags":[167,176,234,235,241,296,319,471,472,585,723,885,895,960,1637,978,997,1173,1319,1473],"class_list":["post-10679","post","type-post","status-publish","format-standard","hentry","category-elearning","category-operating-system","category-tutorials","category-xcode","tag-bubble-sort","tag-c","tag-command-line","tag-command-line-arguments","tag-compile","tag-data-type","tag-desktop","tag-function","tag-function-call","tag-ide","tag-mac","tag-operating-system-2","tag-overloading","tag-pointer","tag-pointers","tag-preprocessor-directives","tag-programming","tag-sort","tag-tutorial","tag-xcode"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/10679"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=10679"}],"version-history":[{"count":1,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/10679\/revisions"}],"predecessor-version":[{"id":16102,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/10679\/revisions\/16102"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=10679"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=10679"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=10679"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}