50_logical_second_arg.c 508 B

123456789101112131415161718192021222324252627282930
  1. #include <stdio.h>
  2. int fred()
  3. {
  4. printf("fred\n");
  5. return 0;
  6. }
  7. int joe()
  8. {
  9. printf("joe\n");
  10. return 1;
  11. }
  12. int main()
  13. {
  14. printf("%d\n", fred() && joe());
  15. printf("%d\n", fred() || joe());
  16. printf("%d\n", joe() && fred());
  17. printf("%d\n", joe() || fred());
  18. printf("%d\n", fred() && (1 + joe()));
  19. printf("%d\n", fred() || (0 + joe()));
  20. printf("%d\n", joe() && (0 + fred()));
  21. printf("%d\n", joe() || (1 + fred()));
  22. return 0;
  23. }
  24. /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/