View Code of Problem 23

#include <stdio.h>
int main()
{
	int i,j,m;
  	long int a[1000]={0,1};
  	while(scanf("%d",&m)!=EOF&&m!=0)
        {

        	for(i=2;i<=m+1;i++)
                  a[i]=a[i-1]+a[i-2];
      		printf("%ld\n",a[i);
        }
}
/*
Main.c: In function 'main':
Main.c:11:27: error: expected ']' before ')' token
         printf("%ld\n",a[i);
                           ^
Main.c:4:8: warning: unused variable 'j' [-Wunused-variable]
  int i,j,m;
        ^
*/

Double click to view unformatted code.


Back to problem 23