answersLogoWhite

0


Best Answer

#include

#include

main()

{

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);

}

getch();

}

Output :

Enter Fibonacci series of nth term : 7

0 1 1 2 3 5 8

Answer 2:/************************************************************************* Fibonacci In a Fibonacci series each number is the sum of the two previous numbers. This program calculates Fibonacci numbers within an 8-bit range, ;************************************************************************/

#include < p18f452.h >

//these memory locations hold the Fibonacci series

unsigned char fib0; //lowest number

//(oldest when going up, newest when reversing down)

unsigned int fib1; //middle number

unsigned float fib2; //highest number

unsigned double fibtemp; //temporary location for newest number

main ()

{

counter 3; //have preloaded the first three numbers, so start at 3

fib0 0;

fib1 1;

fib2 1;

loop: do

{

float test0;

fibtemp fib1 + fib2;

counter counter + 1;

//now shuffle numbers held, discarding the oldest

fib0 fib1; //first move middle number, to overwrite oldest

fib1 fib2;

fib2 fibtemp;

}

while (counter<12):

//when reversing down, we will subtract fib0 from fib1 to form new fib0

do

{

fibtemp fib1 - fib0; //latest number now placed in fibtemp

counter counter - 1;

//now shuffle numbers held, discarding the oldest

fib2 fib1; //first move middle number, to overwrite oldest

fib1 fib0;

fib0 = fibtemp;

}

while (fib0>0);

go to loop

return 10;

}

tell me problem

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a program to generate the Fibonacci Series?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Write a c program Fibonacci series using for loop in java?

Exactly what do you mean by 'C program in Java'


Write a c program to generate Fibonacci series using copy constructor?

#include #include void main(void) { int i,j,k,n; clrscr(); i=0; j=1; printf("%d %d ",i,j); for(n=0;n&lt;=5;n++) { k=i+j; i=j; j=k; printf("%d ",k); } getch(); }


Write a java program to print the last digit in Fibonacci series?

Just generate the Fibonacci numbers one by one, and print each number's last digit ie number%10.


Write a program using while loop that generates Fabonaci series up to 200?

//to generate Fibonacci series upto a range of 200....(in C).... #include&lt;stdio.h&gt; main() { int a,b,c,i; a=0; b=1; printf("\n FIBONACCI SERIES .....\t"); i=1; while(i&lt;=(200-2)) { c=a+b; printf("\t%d",c); a=b; b=c; i++; } }


Write a shell program to generate fibnacci series using while loop?

//WAP to print fibonacci series using do-while loop.? using System; class Fibonacci { public static void Main() { int a=1,b=1; int sum=0; Console.Write("Enter Limit:"); int n=Int32.Parse(Console.ReadLine()); Console.Write(a); Console.Write(b); do { sum=a+b; a=b; b=sum; Console.Write(sum); } while(sum&lt;n); } } By-Vivek Kumar Keshari


Write a c program to accept a numbers and generate square root cube and exponential values?

write a c program to accept a number and generate a square root cube and exponential values


Write a java program to generate the Fibonacci Series using for loop?

class Fibonacci { public static void main(String args[]) { System.out.println("enter the number upto u want"); int number=Integer.parseInt(args[0]); int a=0,b=1,c=0; System.out.print(a+" "+b); for(int i=1;i&lt;=number;i++) { c=a+b; System.out.print(c+" "); a=b; b=c; } } } the number are given to the run time where are print the series eg: 5 0 1 1 2 3 5 8 13................


Write a java program to print the result in the series?

If you have the series stored in an array, you loop through the array and print each array element in turn. Another possibility is to print out the numbers in the series as you generate them. In that case, you may not need to store anything (depending on the series, of course).


Algorithm of Fibonacci series in c?

#include&lt;stdio.h&gt; #include&lt;conio.h&gt; int fib(int a); main() { int a; clrscr(); scanf("%d",&amp;a); for(int i=0;i&lt;a;i++) printf("%d\n",fib(i)); } int fib(int a) { if(a==0) return 0; if(a==1) return 1; else return (fib(a-1)+fib(a-2)); }


How do you write a program to print Fibonacci series of n numbers using recursion in cpp?

#include&lt;iostream&gt; unsigned fib (unsigned term, unsigned a=0, unsigned b=1) { if (term&lt;1) return a; return fib (--term, a+b, a); } int main() { std::cout &lt;&lt; "Fibonacci (1000th term): " &lt;&lt; fib (1000) &lt;&lt; std::endl; }


Write a C program to print the following series 112 122 . 1n2?

write a program to print the series 1/12+1/22+.........+1/n2 ?


Write a Fibonacci function then takes an input from the user in main program and pass to function which prints Fibonacci series up to this number in c language by using while statement?

#include#includevoid fibonacci(int x){int f=0,m=-1,n=1,i=0;while(i