/* * Code from class with examples of conditional execution. * Totally meaningless! */ #include int main(void) { int x; printf("x = %d\n", x); printf("enter integer value\n"); /* C-idiomatic way to check for input not numeric */ if (scanf("%d", &x) == 1) { printf("x = %d\n", x); if ((1 <= x) && (x <= 10)) { printf("in range\n"); } else { printf("not in range\n"); } } else { printf("error\n"); if (x == 10) { printf("old value %d is 10\n", x); } else { printf("old value %d is not 10\n", x); } /* * notice what happens when we (probably mistakenly) use * use "=" when we probabl mean "==" */ if (x = 10) { printf("old value %d is 10\n", x); } else { printf("old value %d is not 10\n", x); } } return 0; }