working code :

#include<stdio.h>

 int fib(int n)
{
        if(n==1) return 0;
        if(n==2) return 1;
        return fib(n-1)+fib(n-2);
}

int main()
{
        int n,i,sum=0;

        printf("enter no of terms\t ");
        scanf("%d",&n);
        printf("fibonacci series = \t ");
        for(i=1;i<=n;i++)
        {
                printf("%d\t",fib(i));
                sum+=fib(i);
        }

        printf("\nsum upto %d terms = %d\n",n,sum);
        return 0;
}



rahul

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to