#include <stdio.h>
int main()
{
double first_def;
double secnd_def;
int fibcount;
int max;
double curfib;
int N;
printf ("Please enter the number of loops (int value)... ");
scanf("%d", &max);
if(max <= 0)
{
printf ("Number must be greater than zero... seting to default 20\n");
max = 20;
}
first_def = 0;
secnd_def = 1;
printf("Attempting to calculate fibonacci\n\n");
printf("Loop Fib#\n");
for(fibcount = 1; fibcount <= max; fibcount++)
{
curfib = first_def + secnd_def;
secnd_def = first_def;
first_def = curfib;
printf ("%3d %.0f \n", fibcount, curfib);
}
}
Well, there it is! I am pretty proud of it, too! It will calculate fibonacci to n digits... :D
Since i am new to c (i am moving from QBASIC to C/C++), i would like to hear some criticism about it. Productive only, please... :)