Print fibonacci series

View previous topic View next topic Go down

Print fibonacci series

Post by Admin on Wed Jun 24, 2015 11:02 pm

Write a program to print get limit from user and print that many fibonacci numbers.

Ex. limit=10
    0,1,1,2,3,5,8,13,21

Admin
Admin

Posts : 22
Points : 5354
Join date : 2015-06-24
Age : 23

http://csenpsb.createforum.in

Back to top Go down

Re: Print fibonacci series

Post by vinoveera on Sat Jun 27, 2015 1:57 am

#include<stdio.h>
void main()
{
int f,a=-1,b=1,i,n;
printf("ENTER THE NUM:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
f=a+b;
printf("%d\n",f);
a=b;
b=f;
}
}

vinoveera

Posts : 7
Points : 5304
Join date : 2015-06-27

Back to top Go down

Good work

Post by Admin on Sat Jun 27, 2015 11:38 am

vinoveera wrote:#include<stdio.h>
void main()
{
int f,a=-1,b=1,i,n;
printf("ENTER THE NUM:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
f=a+b;
printf("%d\n",f);
a=b;
b=f;
}
}
Good job VinoVeera... One correction is try to type your program in a aligned format..
For ex.
void main()
{
int f,a=-1,b=1,i,n;
printf("ENTER THE NUM:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
  f=a+b;
  printf("%d\n",f);
  a=b;
  b=f;
  }
}

Admin
Admin

Posts : 22
Points : 5354
Join date : 2015-06-24
Age : 23

http://csenpsb.createforum.in

Back to top Go down

Re: Print fibonacci series

Post by Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum