Computer Science Canada factorial |
Author: | krishon [ Tue Jun 17, 2003 3:09 pm ] | ||
Post subject: | factorial | ||
hey, well, i'm back to programmin already, but this time in c++. i've been trying to figure out some problems that my school has so i'd be ready for next year. I'm tryin to figure out factorials ( for example the factorial of 5 = 5! = 5*4*3*2*1) I've finished it, but for some reason, the answer always comes out to 256 everytime i try it. heres the code
ne help would be great, thx |
Author: | krishon [ Tue Jun 17, 2003 3:50 pm ] |
Post subject: | |
can someone help or does neone know?!?!?!? |
Author: | Catalyst [ Tue Jun 17, 2003 3:54 pm ] | ||
Post subject: | |||
turing has messed u up in c++: = is assignment (u are setting i to 0) == is comparison |
Author: | krishon [ Tue Jun 17, 2003 3:56 pm ] |
Post subject: | |
ohhhhh...ok, thx, i forgot bout that |
Author: | Catalyst [ Tue Jun 17, 2003 3:57 pm ] |
Post subject: | |
these are the kind of mistakes that will slow ur debug drastically |
Author: | krishon [ Tue Jun 17, 2003 4:02 pm ] |
Post subject: | |
wow...it still dusn't work i changed it to i == 0, and it still gives me 256 wutever number i enter...i'm lost |
Author: | Martin [ Tue Jun 17, 2003 4:59 pm ] | ||
Post subject: | |||
First of all, what's up with all of those includes? Here's how I'd do it..
|
Author: | krishon [ Tue Jun 17, 2003 9:08 pm ] |
Post subject: | |
dun't u need the conio.h header file for getch...maybe cuz i'm using c++ builder 5, i dunno if that's different in 6 |
Author: | krishon [ Tue Jun 17, 2003 9:12 pm ] |
Post subject: | |
hmm...ye..i fixed some problems, it all works now, thx...i saw my mistake, i multiplied it by the number instead of i |
Author: | SilverSprite [ Sat Jun 21, 2003 7:50 pm ] | ||
Post subject: | |||
I know this is a bit late.. but i just read over this post.. Here's how i would do it
|