compute the nth mumber in the fibonacci sequence?
Answer Posted / theredplanethavoc
#include<stdio.h>
#include<conio.h>
void main()
{
int a=0,b=1,c,n,i;
clrscr();
printf("Enter n:");
scanf("%d",&n);
printf("The fibonacci sequence is as follows : \n");
for(i=1;i<=n;i++)
{
c=a+b;
printf("%d ",c);
a=b;
b=c;
}
printf("The nth number in the fibonacci sequence is : %d",c);
getch();
}
| Is This Answer Correct ? | 25 Yes | 3 No |
Post New Answer View All Answers
Where are local variables stored in c?
What is a MAC Address?
What is the advantage of an array over individual variables?
What is spaghetti programming?
Differentiate between the expression “++a” and “a++”?
What is the difference between procedural and functional programming?
what do the 'c' and 'v' in argc and argv stand for?
what is ur strangth & weekness
void main(){ int a; a=1; while(a-->=1) while(a-->=0); printf("%d",a); }
What is the difference between declaring a variable by constant keyword and #define ing that variable?
Explain what is the difference between the expression '++a' and 'a++'?
What is register variable in c language?
Are the expressions * ptr ++ and ++ * ptr same?
What is structure in c explain with example?
Is c compiled or interpreted?