c-cplusplusprograms.blogspot.com . Powered by Blogger.

Write a C program to print the Fibonacci series

Using DO -WHILE Loop

#include<stdio.h>
main(){
    int i = 0, j = 1, temp, cnt = 0;
    printf("0 1 ");
    do {
        cnt++;
        temp = i + j;
        i = j;
        j = temp;
        printf("%d ", j);

    } while (cnt <8);

}

0 comments:

Post a Comment