Guest User

Untitled

a guest
Dec 17th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. //facilitating iteration with goto statement.
  4.  
  5. int factorial(int i)
  6. {
  7. int total = 1;
  8. fact_step:
  9. if(!i) goto end;
  10. else {
  11. total *= i--;
  12. goto fact_step;
  13. }
  14. end:
  15. return total;
  16. }
  17.  
  18.  
  19.  
  20. int main(void) {
  21. printf("The factorial of 3 is %d\n", factorial(3));
  22. return 0;
  23. }
Add Comment
Please, Sign In to add comment