| | |
I dont see any difference between these 2 functions, DO YOU?
![]() |
•
•
Join Date: May 2004
Posts: 3
Reputation:
Solved Threads: 0
C Syntax (Toggle Plain Text)
int gcd (int num1, int num2) { int remainder; if (num1 > num2) remainder = num1 % num2; else remainder = num2 % num1; if(remainder!=0) { return gcd(remainder, num1); } return num1; } int gcd2 (int num1, int num2) { int remainder; return ( remainder = ( num1 > num2 ? num1 % num2 : num2 % num1)==0 ? num1 : gcd2(remainder, num1)); }
its bothering me when passed the same parameters to these two above functions, they give different results.
any idea whats up with them
•
•
Join Date: Mar 2004
Posts: 77
Reputation:
Solved Threads: 2
u need extra parentheses around the = assignment
C Syntax (Toggle Plain Text)
return ( (remainder = ( num1 > num2 ? num1 % num2 : num2 % num1) )==0 ? num1 : gcd2(remainder, num1));
![]() |
Similar Threads
- Hmmm, can anyone help with Depth First Search? (C++)
- Difference b/w stored proc and functions (MS SQL)
- Javascript Problem with Firefox (JavaScript / DHTML / AJAX)
- What is most important? (Monitors, Displays and Video Cards)
- shutdown or powerdown issue for medion PC (Windows NT / 2000 / XP)
- Whats Wrong Withj This 6800 Graphic Card (Monitors, Displays and Video Cards)
- The difference between functions and templates? (C++)
Other Threads in the C Forum
- Previous Thread: XP style in DOS !
- Next Thread: Can you add pictures/sounds in a win32 console app?
| Thread Tools | Search this Thread |
#include adobe ansi api array asterisks binarysearch changingto char character cm copyimagefile cprogramme creafecopyofanytypeoffileinc createcopyoffile csyntax database directory dynamic execv feet fgets file fork forloop frequency function getlasterror givemetehcodez global grade graphics gtkgcurlcompiling hacking hardware highest histogram i/o include incrementoperators infiniteloop input interest kernel keyboard kilometer license linked linkedlist linux linuxsegmentationfault list locate logical_drives looping loopinsideloop. lowest match matrix meter microsoft motherboard mqqueue mysql number odf opensource owf pattern pdf performance pointer posix probleminc process program programming radix recursion recv repetition research reversing scanf segmentationfault sequential shape socket socketprograming standard string systemcall threads turboc unix user voidmain() wab windows.h windowsapi





