int main(const int argc, const char** argv) {
// print the first 10 Fibonacci numbers recursively
fib_rec(10);
// print the first 10 Fibonacci numbers iteratively
fib_it(10);
return 0;
}
// simple starting interface for recursive algorithm
void fib_rec(const unsigned int max) {
}
// recursive part of algorithm
}
}
// iterative solution
void fib_it(const unsigned int max) {
}
}
Exactly what do you mean by 'C program in Java'
You mean you have written a program, but you don't understand it? Well, how could I explain it without seeing it?
i dn't know. haha
//to generate Fibonacci series upto a range of 200....(in C).... #include<stdio.h> main() { int a,b,c,i; a=0; b=1; printf("\n FIBONACCI SERIES .....\t"); i=1; while(i<=(200-2)) { c=a+b; printf("\t%d",c); a=b; b=c; i++; } }
Yes, this can be done. For example for Fibonacci series. You will find plenty of examples if you google for the types of series you need to be generated.
#include #include void main() { clrscr() int a=0,b=1,c,i,n; coutn cout
/*WAP to display Fibonacci series*/ #include<stdio.h> #include<conio.h> void main() { int i,a=0,b=1,c; scanf("%d",&n); printf("%d\n%d",a,b); for(i=0;i<n;i++) { c=a+b; a=b; b=c; printf("\n%d",c); } getch(); }
[ Fibonacci series___: ] #include<stdio.h> int main(void) { int n,i,c,a=0,b=1; printf("Enter Fibonacci series of nth term : "); scanf("%d",&n); printf("%d %d ",a,b); for(i=0;i<=(n-3);i++) { c=a+b; a=b; b=c; printf("%d ",c); } }
to print the Fibonacci series until 100 you can take the input in d to make it run for whatever value you want void main(){ int a,b,c,d; a=0; b=1; c=1; d=100; while(c<d) { printf("%d\n",c); c=a+b; a=b; b=c; } }
see the program
find the program in c-pgms.blogspot.com
#include<stdio.h> #include<conio.h> void main() { printf("The first 20numbers of Fibonacci series are:"); int a=0, b=1, c, n=2; printf("%d \t, %d", &a, &b); while(n<20) { c=a+b; printf("\t %d", &c); a=b; b=c; n++; } getch(); }