Answered Questions

  • Write a program to implement the Fibonacci series

    Star Read Best Answer

    Editorial / Best Answer

    baseersd  

    • Member Since Jun-2007 | Jul 27th, 2007


    Code
    1.  
    2. #include
    3. int main()
    4. {
    5. unsigned int i = 0, j = 0, sum = 1, num;
    6. printf("nEnter the limit for the series ");
    7. scanf("%d", &num);
    8. while (sum < num) {
    9. printf("%d ", sum);
    10. i = j;
    11. j = sum;
    12. sum = i + j;
    13. }
    14. getch();
    15. }
    16.  

    keerthi

    • Jun 7th, 2013

    Code for fibonacci series

    Code
    1. #include<stdio.h>
    2. void main(){
    3. int i=0,j=1,sum=0,num;
    4. printf("enter the size of the series");
    5. scanf("%d",&num);
    6. while(sum<num){
    7. printf("%d",sum);
    8. i=j;
    9. j=sum;
    10. sum=i+j;
    11. }
    12. getch();
    13. }
    14.  

    n.m.sudesh kumar

    • Mar 20th, 2013

    Code
    1. #include<stdio.h>
    2. #include<conio.h>
    3. void main()
    4. {
    5. int pre=0,next=1,sum=0,n;
    6. clrscr();
    7. printf("enter the value of n:");
    8. scanf("%d",&n);
    9. while(pre<=n)
    10. {
    11. printf("the fibonacci series; %d
    12. ",pre);
    13. sum=pre+next;
    14. pre=next;
    15. next=sum;
    16. }
    17. getch();
    18. }