/* * simple example of defining and using functions * and using library function sqrt() (must compile with -lm). */ #include #include /* function declarations / prototypes */ /* add two integers */ int add(int a, int b); /* print numbers from n down through 0 */ void countdown(int n); /* main program */ int main(void) { int x, y; printf("enter two integers\n"); if (scanf("%d %d", &x, &y) == 2) { printf("x, y, sum %d %d %d\n", x, y, add(x, y)); countdown(x); printf("sqrt of x %f\n", sqrt(x)); return 0; } else { printf("not numbers\n"); return 1; } } /* function definitions */ int add(int a, int b) { return a+b; } void countdown(int n) { if (n >= 0) { printf("%d\n", n); countdown(n-1); } }