I've just been trying to put together a small piece of code to display the Fibonacci series up to the nth term, where n is defined by the user.
I have got it working in a way, it is displaying the series up the the nth term where n is defined within the code, however I can't figure out how to get it so the user enters a value and this is used as n.
If anybody could help me along I would be extremely grateful.
Shown below is my code to get it to show the series up to the nth term, with n defined in the For loop.
#include<stdio.h>
int main()
{
int i,j,k,n;
i=0;
j=1;
printf("%d %d ",i,j);
for(n=0;n<=5;n++)
{
k=i+j;
i=j;
j=k;
printf("%d ",k);
}
}