#include<stdio.h>
void main()
{
int a,b,c=0,n;
a=0;
b=1;
printf("Give the range to print fibonacci series");
scanf("%d",&n);
printf("%d%d\n",a,b);
while(c<=n)
{
c=a+b;
if(c<=n)
{
printf(" \nThe fibonacci series are %d",c);
a=b;
b=c;
}
}
}
OUTPUT:
Give the range to print fibonacci series 10
The fibonacci series are
0
1
1
2
3
5
8
void main()
{
int a,b,c=0,n;
a=0;
b=1;
printf("Give the range to print fibonacci series");
scanf("%d",&n);
printf("%d%d\n",a,b);
while(c<=n)
{
c=a+b;
if(c<=n)
{
printf(" \nThe fibonacci series are %d",c);
a=b;
b=c;
}
}
}
OUTPUT:
Give the range to print fibonacci series 10
The fibonacci series are
0
1
1
2
3
5
8
No comments:
Post a Comment