/* * "count up" from N to M by I, recursively */ #include /* * "count up" from start to end by incr */ void count(int start, int end, int incr) { if (incr > 0) { if (start > end) { printf("THE END\n"); } else { printf("%d\n", start); count (start+incr, end, incr); } } else if (incr < 0) { if (start < end) { printf("THE END\n"); } else { printf("%d\n", start); count (start+incr, end, incr); } } else { printf("increment must be nonzero\n"); } } /* main program */ int main(void) { int N, M, I; printf("enter start, stop, increment\n"); if (scanf("%d %d %d", &N, &M, &I) == 3) { count(N, M, I); return 0; } else { printf("not number\n"); return 1; } }