EmbLogic's Blog

fibonacci series using pointer

1 #include
2 #include
3 int main()
4 {
5 int a,b,c,i,n;
6 b=0;
7 c=1;
8 printf(“enter the value \n”);
9 scanf(“%d”,&a);
10 int *d;
11 d=(int*)malloc(sizeof(a));
12 *(d+0)=0;
13 *(d+1)=1;
14 i=2;
15 while(i<a)
16 {
17 *(d+i)=b+c;b=c;c=*(d+i);
18 i++;
19 }
20 for(i=0;i<a;i++)
21 printf("%d\n",*(d+i));
22 }

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>