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
string reverse using recursion
What is a void pointer? When is a void pointer used?
What is character set?
How can you invoke another program from within a C program?
Is it acceptable to declare/define a variable in a c header?
How is = symbol different from == symbol in c programming?
What is a pointer value and address in c?
typedef struct{ char *; nodeptr next; } * nodeptr ; What does nodeptr stand for?
What are the advantages of c language?
What happens if a header file is included twice?
What is a pragma?
When can a far pointer be used?
Why we use break in c?
what is the c source code for the below output? 10 10 10 10 10 10 10 10 10 10 9 9 7 6 6 6 6 6 6 9 7 5 9 7 3 2 2 5 9 7 3 1 5 9 7 3 5 9 7 4 4 4 4 5 9 7 8 8 8 8 8 8 8 8 9
What is the advantage of using #define to declare a constant?