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


Please Help Members By Posting Answers For Below Questions

What does a function declared as pascal do differently?

617


What is string in c language?

632


Is int a keyword in c?

565


How can I get the current date or time of day in a c program?

656


Should I learn c before c++?

639






What are high level languages like C and FORTRAN also known as?

693


What are the advantages and disadvantages of a heap?

716


Are bit fields portable?

684


Explain what is gets() function?

641


By using C language input a date into it and if it is right?

578


What is the 'named constructor idiom'?

647


How many levels of pointers have?

602


How are 16- and 32-bit numbers stored?

731


pgm to find any error in linklist(in single linklist check whether any node points any of previous nodes instead of next node)

2206


Explain 'bus error'?

569