how can i write a program in c using fibonacci series upto 200 numbers & using for loop statement ???
how can i write a program in c using fibonacci series upto 200 numbers & using for loop statement ???
How much of the language do you know?
You need to find some tutorials - google around or buy some books, or goto www.cprogramming.com
Not sure what DaniWebs homework policy is since I've only just become a member myself, but where I usually moan and groan (cboard), we don't do it for you.
tht wuz not answer to my question.......btw wot do u mean by "we dont do it for u" ???
i have written that using "for loop"
Binet's formula:
[tex]Fib(n)=\frac{\phi^n-(-\phi)^n}{\sqrt{5}}[/tex]
Where [tex]\phi[/tex] is equal to:
[tex]\frac{1+\sqrt{5}}{2}[/tex]
Hope this helps :-)
thank you so much but tht wuz not helpful for me.....
thank you so much but tht wuz not helpful for me.....
Of course it is, if you are using fast fourier transforms to approximate the power functions and a library that supports arbitary floating point precision it will be perfect for you.
:-)
tht wuz not answer to my question.......btw wot do u mean by "we dont do it for u" ???
i have written that using "for loop"
Well post up what you've got so far so we can help you.
hello I found this I hope this helps
#include<stdio.h>
#define SIZE_NUM 100000000
#define VECTOR_DIM 500//max fib(10000)
#define display_arr(vec)for(i=indfin-1; i>-1; i--){temp=SIZE_NUM/10;if(i!=indfin-1)while(1){if(vec/temp) break;putchar('0');temp/=10;}printf("%d", vec);}
int main()
{int i=-1, opt;int indfin=1, ref=1;
unsigned int n0[VECTOR_DIM] = {0}, n1[VECTOR_DIM] = {1};
unsigned int temp;printf("Enter fib(n)");
scanf("%d", &opt);if(!opt)
printf("The Fibonacci number for 0 is 0");else{
while(i++<opt){indfin=0;
if(ref){while(temp = n0[indfin] + n1[indfin]){
n0[indfin] = temp%SIZE_NUM;n0[indfin+1] = temp/SIZE_NUM + n0[indfin+1];
indfin++;}ref=0;}else{while(temp = n0[indfin] + n1[indfin]){
n1[indfin] = temp%SIZE_NUM;n1[indfin+1] = temp/SIZE_NUM + n1[indfin+1];
indfin++;}ref=1;}}printf("The Fibonacci number for %d is \n ", opt);
if(ref) display_arr(n0)
else display_arr(n1)}putchar('\n');getchar();getchar();return 0;}
btw my binets formula was wrong... the minus phi needs to be raised to the minus n. tee he he
[edit] I've indented and highlighted keywords to aid clarity, in case you decide to submit as your own work[/edit]
We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.