/* an illustration of the if-else ladder G.C. Rutledge September 2002 */ #include int main(void) { int first,second; char flag; /* repeat the following block of statements as many times as desired */ do { printf("Enter two booleans (i.e. 1 or 0): \n"); scanf("%d%d",&first,&second); /* test for values entered by user */ if(first&&second) printf("both true\n"); else if(first||second) printf("one or the other is true, but not both\n"); else printf("both false\n"); printf("Enter 'q' to quit, anything else to continue\n"); scanf("\n%c",&flag); } while(flag!='q'); return(0); }