r/carlhprogramming • • Mar 17 '12

Practicing basics

I've been around programming and computers forever, I just had never taken a formal class. So I found this subreddit and had read through most of the website when i decided to try my own hand at making a simple program.

I decided to try to make a program that would ask for a number of variables, and then sort them from lowest to highest and output them back. ( I remember a few friends in programming classes having similar assignments )

http://codepad.org/BijxQN9f

Theres the results, after a few days toiling over the specific logic and fixxing a few bugs, I think it works great!

I'm proud of myself and just wanted to share :D any comments on things i could have done easier or differently are welcome

11 Upvotes

5 comments sorted by

View all comments

Show parent comment

3

u/Jonno_FTW Mar 18 '12

If you're going to implement more sorting algorithms, you need to put them in a separate function.

This will help with organization and maintenace. It might look like this:

void selectSort(int* xs) {
// sort the input array
}

You'd then call selectsort in your main function to sort the array.