This
preview
has intentionally blurred sections.
Sign up to view the full version.
Unformatted text preview: A way to avoid this would be to say: /* return -1 on error, else 0 */ int f(int a, int b) { const double f = (a <= 0 || b <= 0 ? 0.0 : fact(25)); if (a <= 0 || b <= 0) return -1; /* use f in calculations */ return 0; } but the logic is a bit torturous. In C++, using declaration statements (see above), this problem can be avoided entirely, by saying: /* return -1 on error, else 0 */ int f(int a, int b) { if (a <= 0 || b <= 0) return -1; const double f = fact(25); /* use f in calculations */ return 0; }...
View
Full Document
- Fall '08
- Staff
- Recursion, Prime number, Programming constructs, Articles with example C code, Gamma function
-
Click to edit the document details