Fibonacci series.

#include<stdio.h>
#include<conio.h>
void main()
{
 int n,a,b,c;
 int i=2;
 clrscr();
 printf("Enter number of terms=");
 scanf("%d",&n);
 printf("enter 1st term=");
 scanf("%d",&a);
 printf("enter 2nd term=");
 scanf("%d",&b);
 printf("%d ",a);
 printf("%d ",b);
 while(i<n)
 {
  c=a+b;
  printf("%d ",c);
  i=i+1;
  a=b;
  b=c;
 }
 getch();
 }
■》 Output->

Enter number of terms=6
enter 1st term=0
enter 2nd term=1

0   1  1   2  3  5

Comments

Popular posts from this blog

Introduction of java Programming language.

Stack data structure.