Twitter Feed Facebook Google Plus Youtube

Adsense responsive

Recent Post below header

Tuesday, 5 February 2013

C PROGRAM: TO PRINT FIBONACCI SERIES UPTO N TERMS USING FUNCTION

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);
}
}


CODING

OUTPUT


For any query or suggestion please comment below...

7 comments:

  1. which data type should be used to print first 100 fibonacci series number. reply me......

    ReplyDelete
    Replies
    1. You can use short int. Also one suggestion for admin, please remove clrscr, as they are not supported in most of the compiler.
      See this : Best c compiler for windows

      Delete
  2. can you plzzz tell me where from this "m" is coming? u have declared integer "n,i" not m!!!

    ReplyDelete
    Replies
    1. [Admin] Please see function prototype "int fib(int m,int n)". It has declaration of variable m (int m).
      :)

      Delete
  3. Warning in the 24: Function should return a value

    ReplyDelete
    Replies
    1. Return type of fib() should be void.
      [Updated above program.]

      Delete