/* * simple examples of conditional execution, including scanf error check */ #include int main(void) { int a; printf("enter an integer\n"); /* read variable with simple check for error */ if (scanf("%d", &a) == 1) { printf("a = %d\n", a); } else { printf("not an integer\n"); } /* "switch" to select from among cases */ switch(a) { case 0: printf("zero\n"); break; case 1: printf("one\n"); break; case 2: case 3: printf("two or three\n"); break; default: printf("other\n"); break; } return 0; }