c programming anyone?
I need a quick answer as to why this program isn't working the way I want .. Task is to get the next lower or higher fibonacci number from the number you chose:
#include
#include
void main()
{
int fib[100];
int i,n,x, kind, y, z;
printf("How many Fibonacci numbers you want:");
scanf("%d",&n);
fib[0] = 0;
fib[1] = 1;
printf("\n\nSerial Fibonacci number\n\n");
for(i = 2; i < n; i++)
fib[i] = fib[i-1] + fib[i-2];
for (i = 0; i < n; i++)
printf("%3d %6d\n", i, fib[i]);
printf("Choose upper -u- or lower case -l-:");
scanf("%d", &kind);
printf ("Choose a number y:");
scanf("%d", &y);
if (kind == "u") {
printf("\n\%d\n", y= fib[i>y]);
}
else (kind == "l"); {
printf("\n\%d\n", z= fib[i }
getch();
}
Comments