/* Program: short2.c Another program to demonstrate short circuit evaluation. */ #include #include "genlib.h" #include "simpio.h" main() { int a, n ; a = 5 ; printf("n = ? ") ; n = GetInteger() ; /* Checking for division by zero */ if ( (n != 0) && (a/n > 1) ) { printf("Yes, a/n > 1\n") ; } else { printf("No, a/n <= 1\n") ; } /* Now we crash the program when n is zero */ a = a / n ; printf("This part is after the division.\n") ; } --------------------------------------------------- lassie% cc201 short2.c lassie% a.out n = ? 2 Yes, a/n > 1 This part is after the division. lassie% lassie% a.out n = ? 6 No, a/n <= 1 This part is after the division. lassie% lassie% a.out n = ? 0 No, a/n <= 1 Trace/BPT trap (core dumped) lassie%