View Single Post
  #4   Spotlight this post!  
Unread 14-10-2004, 01:03
rbayer's Avatar Unsung FIRST Hero
rbayer rbayer is offline
Blood, Sweat, and Code
no team (Teamless Orphan)
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Minnetonka, MN
Posts: 1,087
rbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of light
Send a message via AIM to rbayer
Re: i would like your opinion on my programs

First of all, excellent work for someone just starting out with C. A few comments though to help make the transition from just playing with C to actually using it well:
First, unless you absolutely need to represent fractional numbers, you should always try avoid using doubles. They are _incredibly_ slow compared to ints. Since both factorial and permutations are purely integer functions, you would be much better off with simply using ints.
Second, code modularity is very good thing. If you have some time, I'd definately try re-writing your programs so that factorial is a function that you can call from within your permutation program. This idea of re-usable code and breaking things into smaller functions is the key to really using C well.
Third, global variables are a bad thing (unless you've got a darn good reason for using them). You can easily fix this by just moving your variable declarations to be inside the function where you want them.

Anyways, as I said, nice work and good luck learning C!

Rob
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php