Q1: Write a C program to print "Fibonacci Sequence" as an output?
#include<conio.h>
#include<stdio.h>
void main()
{
//fibonacci series
int a=0,b=1,i,c=0;
clrscr();
for(i=1;i<=10;i++)
{
printf("%d\t",c);
a=b;
b=c;
c=a+b;
}
getch();
}
***********************************************************************************
Sample Output:
#include<conio.h>
#include<stdio.h>
void main()
{
//fibonacci series
int a=0,b=1,i,c=0;
clrscr();
for(i=1;i<=10;i++)
{
printf("%d\t",c);
a=b;
b=c;
c=a+b;
}
getch();
}
***********************************************************************************
Sample Output:
Comments
Post a Comment
Thanks for the comment and don't forget to subscribe.