C Program Fibonacci Series
/* Write a Program to print Fibonacci series.(1 1 2 3 5 8 13……) */
#include <stdio.h>
int main(void) {
int a=1,b=1,n;
printf("How Many Fibonacci No of you want to print : ");
scanf("%d",&n);
printf("\n %d %d ",a,b);
while(n>0)
{
printf("%d ",a+b);
b=a+b;
a=b-a;
n--;
}
return 0;
}
#include <stdio.h>
int main(void) {
int a=1,b=1,n;
printf("How Many Fibonacci No of you want to print : ");
scanf("%d",&n);
printf("\n %d %d ",a,b);
while(n>0)
{
printf("%d ",a+b);
b=a+b;
a=b-a;
n--;
}
return 0;
}
Comments
Post a Comment