C program to print fibonacci series in reverse order
Input:
Enter n to print n fibonacci numbers in reverse:
10
Output:
34 21 13 8 5 3 2 1 1 0
Implementation:
Input:
Enter n to print n fibonacci numbers in reverse:
10
Output:
34 21 13 8 5 3 2 1 1 0
Implementation:
#include <stdio.h> #include <stdlib.h> #define MAX 1000000 void findfibo(int fib[],int n) { int i; for(i=2;i<n;i++) { fib[i]=fib[i-1]+fib[i-2]; } } void printreverse(int fib[],int n) { int i; findfibo(fib,n); for(i=n-1;i>=0;i--) { printf("%d ",fib[i]); } } int main(void) { int fib[MAX]; int n; fib[0]=0; fib[1]=1; printf("Enter n to print n fibonacci numbers in reverse:\n"); scanf("%d",&n); printreverse(fib,n); return 0; }