My instructions were to write a program that displays the first 20 elements of the Fibonacci series, that begins with 0, 1, then the next numbers come from adding the preceeding two numbers.
0, 1, 1, 2, 3, 5, 8...
Here is what I have so far:
#include <stdio.h>
int main(void)
{
int current, prev = 1, prevprev = 0;
for (int i = 0; i < 20 i++)
{current = prev + prevprev;
printf(current + " ");
prevprev = prev;
prev = current;
}
println();
}
}
Do I have the right idea? Please help...
Also part of my instructions (i'm not sure if how to do this part either) are that I only display 5 members of the series per line, then start a new line, and they must be dspaced neatly in 5 columns across the screen, and display some appropriate title...boy these instructors are neat freaks!
thanks for you time and help,
-James