/*C Program To Print Fibonacci Series */ #include <stdio.h> #include <stdlib.h> int main() { int f1=1,f2=1,f3,i=1,n,sum=0; printf("Enter the value:\n"); scanf("%d",&n); printf("----------------\n"); do{ printf("%d\n",f1); sum=sum+f1; f3=f2+f1; f1=f2; f2=f3; i++; }while(i<=n); printf("Sum Of The Series = %d\n",sum); return 0; }
Enter the value: 6 ---------------- 1 1 2 3 5 8 Sum Of The Series = 20
No comments:
Post a Comment