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
What does a function declared as pascal do differently?
What is string in c language?
Is int a keyword in c?
How can I get the current date or time of day in a c program?
Should I learn c before c++?
What are high level languages like C and FORTRAN also known as?
What are the advantages and disadvantages of a heap?
Are bit fields portable?
Explain what is gets() function?
By using C language input a date into it and if it is right?
What is the 'named constructor idiom'?
How many levels of pointers have?
How are 16- and 32-bit numbers stored?
pgm to find any error in linklist(in single linklist check whether any node points any of previous nodes instead of next node)
Explain 'bus error'?