| | |
I dont see any difference between these 2 functions, DO YOU?
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
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?
Views: 2940 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for C
#include * .net append array arrays asterisks binarysearch calculate changingto char character cm command copyimagefile cprogramme creafecopyofanytypeoffileinc database directory dynamic execv feet fgets file fork forloop framework function functions givemetehcodez grade graphics gtkwinlinux hacking histogram homework include incrementoperators input intmain() iso kernel keyboard km lazy license linked linkedlist linux list lists locate logical_drives looping loopinsideloop. lowest matrix microsoft mqqueue mysql number oddnumber odf opensource overwrite owf pdf performance pointer pointers posix probleminc process program programming radix recursion recv recvblocked research reversing scanf scripting segmentationfault sequential socket spoonfeeding standard string student systemcall testing threads turboc unix user variable wab whythiscodecausesegmentationfault windowsapi





