fork(3) download
  1. #include <stdio.h>
  2.  
  3. void allEven(int number, int *result);
  4.  
  5. int main()
  6. {
  7. int num;
  8. int result = 1;
  9. printf("Enter a number: ");
  10. scanf("%d", &num);
  11. allEven(num, &result);
  12. printf("allEven(): %d", result);
  13. return 0;
  14.  
  15. }
  16. void allEven(int number, int *result)
  17. {
  18. if ((number % 10) % 2) // if the last digit is odd
  19. {
  20. *result = 0;
  21. }
  22. else
  23. {
  24. *result = 1;
  25. if ((number / 10) != 0) //not the last digit to evaluate, we call the function again.
  26. {
  27. allEven((number / 10), result);
  28. }
  29. }
  30. }
  31.  
Success #stdin #stdout 0s 2012KB
stdin
556
stdout
Enter a number: allEven(): 0