#include<stdio.h>
#include<conio.h>
int main(){
int n,c,i;
int fib(int x);
clrscr();
printf("How many terms do you want in fibonacci series\n");
scanf("%d",&n);
if(n>0){
printf("Fibonacci Series is:\n");
for(i=0;i<=n-1;i++){
c=fib(i);
printf("%d ",c);
}
}
else{
printf("Wrong Value Inserted\n Try Again!!\n");
}
getch();
return 1;
}
int fib(int x){
if(x==0)return 0;
if(x==1)return 1;
return (fib(x-2)+fib(x-1));
}
#include<conio.h>
int main(){
int n,c,i;
int fib(int x);
clrscr();
printf("How many terms do you want in fibonacci series\n");
scanf("%d",&n);
if(n>0){
printf("Fibonacci Series is:\n");
for(i=0;i<=n-1;i++){
c=fib(i);
printf("%d ",c);
}
}
else{
printf("Wrong Value Inserted\n Try Again!!\n");
}
getch();
return 1;
}
int fib(int x){
if(x==0)return 0;
if(x==1)return 1;
return (fib(x-2)+fib(x-1));
}
No comments:
Post a Comment