23.12.19

Fibonacci sequence program in c

#include<stdio.h>
 void main()
{

int a,b,c=0,n;

a=0;
b=1;

printf("Give the range to print fibonacci series");
 scanf("%d",&n);

printf("%d%d\n",a,b);
while(c<=n)
{

c=a+b;

if(c<=n)
{

printf(" \nThe fibonacci series are %d",c);

a=b;
b=c;
}
}
}



OUTPUT:
Give the range to print fibonacci series 10

The fibonacci series are

0
1
1
2
3
5
8

No comments:

Post a Comment

JAVA program pattern 2

import java.util.Scanner; public class pattern3 { public static void main(String args[]) { int i,j; Scanner sc=new Scanner(System.in); Syste...