compute the nth mumber in the fibonacci sequence?

Answer Posted / d. prashant

#include<stdio.h>
#include<conio.h>
void main()
{
int a =0,b=1,c,i=2,n;
clrscr();
printf("Enter N Value : ");
scanf("%d",&n);
printf("%d\t%d\t",a,b);
while(n>i)
{
c = a+b;
printf("%d\t",c);
c=b;
b=a;
i++;
}
getch();
}

Is This Answer Correct ?    3 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the characteristics of arrays in c?

605


Lists the benefits of c programming language?

585


What is the difference between printf and scanf in c?

741


How to create struct variables?

584


Program to find the sum of digits of a given number until the sum becomes a single digit. (e.g. 12345=>1+2+3+4+5=15=>1+5=6)

682






What is size of union in c?

575


The __________ attribute is used to announce variables based on definitions of columns in a table?

663


please explain every phase in the "SDLC" in the dotnet.

2174


the factorial of non-negative integer n is written n! and is defined as follows: n!=n*(n-1)*(n-2)........1(for values of n greater than or equal to 1 and n!=1(for n=0) Perform the following 1.write a c program that reads a non-negative integer and computes and prints its factorial. 2. write a C program that estimates the value of the mathematical constant e by using the formula: e=1+1/!+1/2!+1/3!+.... 3. write a c program the computes the value ex by using the formula ex=1+x/1!+xsquare/2!+xcube/3!+....

22182


When should a type cast not be used?

620


main() { int i = 10; printf(" %d %d %d ", ++i, i++, ++i); }

628


How do I round numbers?

591


The postoder traversal is 7,14,3,55,22,5,17 Then ur Inorder traversal is??? please help me on this

2920


Does sprintf put null character?

590


What is #include stdio h?

674