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

How pointer is different from array?

569


WHICH TYPE OF JOBS WE GET BY WRITING GROUPS .WHEN THE EXAMS CONDUCTED IS THIS EXAMS ARE CONDUCTED EVERY YEAR OR NOT.PLS TELL ME THE ANSWER

1453


the constant value in the case label is followed by a a) semicolon b) colon c) braces d) none of the above

717


Can you explain what keyboard debouncing is, and where and why we us it? please give some examples

1646


Why is extern used in c?

606






What is the purpose of 'register' keyword?

683


Hai sir, I had planned to write the NIC scientific engineer exam , plz post the sample question......

1737


I completed my B.tech (IT). Actually I want to develop virtual object that which will change software technology in the future. To develop virtual object what course I have to take. can I any professor to help me.

1733


What is use of integral promotions in c?

658


Is null always equal to 0(zero)?

575


What is a program?

650


In the DOS enveronment, normal RAM that resides beyond the 1mb mark. a) expanded memory b) swapped memory c) Extended memory d) none

707


Explain how do you declare an array that will hold more than 64kb of data?

887


how to execute a program using if else condition and the output should enter number and the number is odd only...

1648


cavium networks written test pattern ..

3584