compute the nth mumber in the fibonacci sequence?

Answer Posted / sree

#include<stdio.h>
#include<conio.h>
void main()
{
int n,a=-1,b=1,c;
printf("Enter n:");
scanf("%d",&n);
for(int i=0;i<=n;i++)
{
c=a+b;
a=b;
b=c;
}
printf("Answer:%d",c);
}

Is This Answer Correct ?    9 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

can we change the default calling convention in c if yes than how.........?

2037


what is associativity explain what is the precidence for * and & , * and ++ how the folloing declaration work 1) *&p; 2) *p++;

1892


write a program that reads lines(using getline), converts each line to an integer using atoi, and computes the average of all the numbers read. also compute the standard deviation.

1988


What does *p++ do? What does it point to?

620


why programs in c are running with out #include? some warnings are display in terminal but we execute the program we get answer why? eg: main() { printf("hello world "); }

1320






What is the difference between union and anonymous union?

841


How do I read the arrow keys? What about function keys?

618


What is the advantage of an array over individual variables?

746


Do pointers take up memory?

664


What does %c mean in c?

656


What will the preprocessor do for a program?

595


a c code by using memory allocation for add ,multiply of sprase matrixes

2306


What is the size of enum in c?

625


how to find anagram without using string functions using only loops in c programming

2720


1) There is a singing competition for children going to be conducted at a local club. Parents have been asked to arrive at least an hour before and register their children’s names with the Program Manager. Whenever a participant registers, the Program Manager has to position the name of the person in a list in alphabet order. Write a program to help the Program Manager do this by placing the name in the right place each time the Program Manger enters a name. The Logic should be written in Data Structures?

1921