Print fibonacci series
2 posters
Page 1 of 1
Print fibonacci series
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
Ex. limit=10
0,1,1,2,3,5,8,13,21
Re: Print fibonacci series
#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;
}
}
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 : 22699
Join date : 2015-06-27
Good work
Good job VinoVeera... One correction is try to type your program in a aligned format..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;
}
}
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;
}
}
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|