/* Fibonacci Series using while loop */
// 0 1 1 2 3 5 8 13...
#include<stdio.h>
int main()
{
int n,i,a,b,c;
printf("Enter a number: ");
scanf("%d",&n);
i=1;
a=0;
b=1;
while(i<=n)
{
printf("%d ",a);
c = a + b;
a = b;
b = c;
i++;
}
return 0;
}
Related Post:
Fibonacci series using for loop
http://cbasicprogram.blogspot.in/2012/03/fibonacci-series-using-for-loop.html
// 0 1 1 2 3 5 8 13...
#include<stdio.h>
int main()
{
int n,i,a,b,c;
printf("Enter a number: ");
scanf("%d",&n);
i=1;
a=0;
b=1;
while(i<=n)
{
printf("%d ",a);
c = a + b;
a = b;
b = c;
i++;
}
return 0;
}
Related Post:
Fibonacci series using for loop
http://cbasicprogram.blogspot.in/2012/03/fibonacci-series-using-for-loop.html
int main()
ReplyDelete{
int i=0,j=1;
int c,n,count=0,d;
cout<<"enter num";
cin>>n;
c=i+j;
cout<<i<<j;
while(count<n-2)
{ d=j+c;
cout<<d;
j=c;
c=d;
count++;
}
return 0;
}
great ... . .its working thnx fr the infrmtn
DeleteAttention everyone, the file provided above is not working. I have been looking for the working file and finally found it.
Delete✔️Click Here To Download http://gestyy.com/e0GAyS
✔️Click Here To Download
✔️Click Here To Download http://exe.io/XONVsO6l
✔️Click Here To Download
✔️Click Here To Download
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Mn.
..
.
.
.
..
.
.
.
.
.
.
.
.
.
.
..
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.xzxz
.sdcccxxx
why did we take i=1 only ?
ReplyDeleteTo start the loop in the series form till the Nth given number
Deletethank u
ReplyDeleteif i will take n=1 only then,
ReplyDeletewill it show result 0? according to me 0 and 1 both will print on the monitor
why we take while(ao,
ReplyDeleteplease suggest me!!
Fibonacci Series in C
ReplyDeleteLovely post, thanks for sharing good article with us.
Nice 👍
ReplyDelete