can someone help there seem to be a problem with my code
Code:#include<stdio.h>#include<conio.h> #include<math.h> main() { int gcd(int a,int b) { int c; while(1) { c = a%b; if(c==0) return b; a = b; b = c; } } getch(); }
can someone help there seem to be a problem with my code
Code:#include<stdio.h>#include<conio.h> #include<math.h> main() { int gcd(int a,int b) { int c; while(1) { c = a%b; if(c==0) return b; a = b; b = c; } } getch(); }
Yes, there's many problems:
- Don't use implicit main > SourceForge.net: Implicit main - cpwiki
- No idea what you're trying to do nesting functions, but it doesn't work
- Lose the getch() and the outdated conio.h header
- Learn how to use while loops correctly, and realize that infinite loops with forced termination are bad code
- Your algorithm seems pretty screwy anyway