#include<stdio.h>
#include<conio.h>
void main(){
int n,a,b,c,i;
clrscr();
printf("Which term do you want from fibonacci series\n");
scanf("%d",&n);
printf("Enter two intial number a and b of fibonacci series\n");
scanf("%d%d",&a,&b);
printf("%d term of fibonacci series = ",n);
if (n>0) {
if (n==1) printf("%d",a);
else {
if (n==2) printf("%d",b);
else {
for (i=1;i<=n-2;i++) {
c=a+b;
a=b;
b=c;
}
printf("%d ",c);
}}}
else printf("Wrong Term\nTry again!!\n");
getch();
}
No comments:
Post a Comment