C program to print the Fibonacci series.

 

C program
C PROGRAM

C program to print the  Fibonacci series

#include<stdio.h>
#include<conio.h>
void main() 
{
    int n,first=0,second=1,next,a;
    clrscr();
    printf("enter the number of terms");
    scanf("%d",&n);
    for(a=0;a<n;a++)
    {
    if(a<=1)
    {
      next=a;
      printf ("%d",next);
      }
      else
      {
      first=second;
      second=next;
      next=first+second;
      printf("%d",first);
      }
      }
      getch();
      }

OUTPUT : 

enter the number of terms10
011123581321
Process finished.

Comments

Popular posts from this blog

Write a program to calculate a students result based on two examinations, 1 sports event, and 3 activities conducted. The weightage of activities= 30%, sports= 20% , and examinations= 50%.

Determine the intensity of shear of an oil having viscosity= 1 poise. The oil is used for lubricating the clearance between a shaft of diameter 10 cm and its journal bearing. The clearance is 1.5mm and the shaft rotates at 150 r.p.m.