0 Members and 1 Guest are viewing this topic.
#include <stdio.h>main() { // This program solves the f91 recursive function for a given number // This program was coded by David printf("Enter number: "); int input; scanf("%d",input); printf("The result is: ",f91(input)); getch(); return 0; }int f91(n) { if (n<101) { return f91(f91(n+11)); } else { return n-10; }}
printf("The result is: %i",f91(input));
Thank you two, now who can explain me what %i stands for? * Scout just googled!Thanks
Quote from: Scout on February 02, 2011, 02:18:03 pmThank you two, now who can explain me what %i stands for? * Scout just googled!Thanks The % is a special token. It tells the compiler that the next symbol (in this case 'i') will be used for specialized text formatting. The 'i' is for a 16 bit integer. Hence, the integer (returned from the call to f91(input)) will be inserted into the string to print to the screen.Take a look at the The C Book: Formatted I/O chapter.
Actually, I'd think it would be a 32-bit integer unless you're using a really old computer. At any rate, it should be used for "int" values.