Monday 5 October 2015

Write a program to print Fibonacci series. 1,1,2,3,5,......N

  
   
#include<stdio.h>
//#include<conio.h>
void main() {
    int n1 = 0, n2 = 1, n3, n, i = 0;
    //clrscr();
    printf("enter n ");
    scanf("%d", &n);
    printf("\n the fibonacci series till the %dth term is::", n);
    do {
        printf("%d ", n1);
        printf("\t");
        n3 = n1 + n2;
        n1 = n2;
        n2 = n3;
        i++;
    } while (i <= n);
    //getch();
}
Note: Remove the comment line when you are use Turbo C IDE for run your program.

No comments:

Post a Comment