Write a program to print the fibonacci series for given "N" value.
#include<stdio.h>
#include<conio.h>
void main()
{
int n,t1=0,t2=1,next;
clrscr();
printf("enterthe no");
scanf("%d",&n);
printf("\n\n7%d%d",t1,t2);
next=t1+t2;
while(next<=n){
printf("\n%d",next);
t1=t2;
t2=next;
next=t1+t2;
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int n,t1=0,t2=1,next;
clrscr();
printf("enterthe no");
scanf("%d",&n);
printf("\n\n7%d%d",t1,t2);
next=t1+t2;
while(next<=n){
printf("\n%d",next);
t1=t2;
t2=next;
next=t1+t2;
}
getch();
}
No comments:
Post a Comment