CODING:
#include<stdio.h>
#include<conio.h>
void main()
{
void fib(int,int),n,i;
clrscr();
printf("Enter no. of elements ");
scanf("%d",&n);
printf(" 0 1");
fib(i,n);
getch();
}
void fib(int m,int n)
{
int a=0,b=1;
int c;
for(m=1;m<=n-2;m++)
{
c=a+b;
a=b;
b=c;
printf("%3d",c);
}
}
#include<stdio.h>
#include<conio.h>
void main()
{
void fib(int,int),n,i;
clrscr();
printf("Enter no. of elements ");
scanf("%d",&n);
printf(" 0 1");
fib(i,n);
getch();
}
void fib(int m,int n)
{
int a=0,b=1;
int c;
for(m=1;m<=n-2;m++)
{
c=a+b;
a=b;
b=c;
printf("%3d",c);
}
}
CODING |
OUTPUT |
For any query or suggestion please comment below...
which data type should be used to print first 100 fibonacci series number. reply me......
ReplyDeleteYou can use int data type.
DeleteYou can use short int. Also one suggestion for admin, please remove clrscr, as they are not supported in most of the compiler.
DeleteSee this : Best c compiler for windows
can you plzzz tell me where from this "m" is coming? u have declared integer "n,i" not m!!!
ReplyDelete[Admin] Please see function prototype "int fib(int m,int n)". It has declaration of variable m (int m).
Delete:)
Warning in the 24: Function should return a value
ReplyDeleteReturn type of fib() should be void.
Delete[Updated above program.]