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 is build process in c?

880


main() { struct s1 { char *str; struct s1 *ptr; }; static struct s1 arr[] = { {"Hyderabad",arr+1}, {"Bangalore",arr+2}, {"Delhi",arr} }; struct s1 *p[3]; int i; < BR> for(i=0;i<=2;i++) p[i] = arr[i].ptr; printf("%s ",(*p)->str); printf("%s ",(++*p)->str); printf("%s ",((*p)++)->str); }

1153


Write a program to identify if a given binary tree is balanced or not.

922


Is there any algorithm to search a string in link list in the minimum time?(please do not suggest the usual method of traversing the link list)

2098


write a program using linked list in which each node consists of following information. Name[30] Branch Rollno Telephone no i) Write the program to add information of students in linked list

2534


#include main() { int *p, *c, i; i = 5; p = (int*) (malloc(sizeof(i))); printf(" %d",*p); *p = 10; printf(" %d %d",i,*p); c = (int*) calloc(2); printf(" %d ",*c); }

850


What does the function toupper() do?

885


What is typedef struct in c?

804


#define f(g,h) g##h main O int i=0 int var=100 ; print f ("%d"f(var,10));} wat would be the output??

1759


What is a nested loop?

874


In C language, a variable name cannot contain?

1018


Why isnt there a numbered, multi-level break statement to break out

821


Write a program in "C" to calculate the root of a quadratic equation ax^2+bx+c=0, where the value of a,b & c are known.

1979


stripos — Find position of first occurrence of a case- insensitive string int stripos ( char* haystack, char* needle, int offset ) Returns the numeric position of the first occurrence of needle in the haystack string. Note that the needle may be a string of one or more characters. If needle is not found, stripos() will return -1. The function should not make use of any C library function calls.

2167


Describe the difference between = and == symbols in c programming?

1018