All pastes #265315 Raw Edit

Miscellany

public text v1 · immutable
·published 2006-12-03 05:03 UTC
rendered paste body
/* counter.c - Script 7.5 */
#include <stdio.h>

void countdown (int start, int end); // function prototype

int main(void) { /* Start main function */

countdown (50, 40); // call countdown function
// Wait for user to pass to next function
getchar();
return 0;

} // End of main() function

/* This function countdowns from start to end using recursion */

void countdown (int start, int end) { // cowntown function defined

printf ("Before: %d\n", start); //Print initial value

--start; //Decrement

if (start > end) { //if end point hasn't been reached, call function again
	countdown (start, end);
}

printf ("After: %d\n", start); // Reprint value of start and complete function

} //End of countdown function