answersLogoWhite

0

#include <iostream.h>

#include <conio.h>

#include <stdlib.h>

int swap(int* , int*);

int main()

{

int c=0;

int b=1;

int max;

cout<<"Enter the maximum limit of fibbonacci series = ";

cin>>max;

if(max>0)

{

cout<<c<<endl;

}

else

{

exit (EXIT_FAILURE);

}

for(int i=0;i<max;i++)

{

c=b+c;

swap(&b,&c);

if(c<max)

{

cout<<c<<endl;

}

else

{

break;

}

}

getch();

return 0;

}

int swap(int *x,int *y)

{

int z;

z=*x;

*x=*y;

*y=z;

return z;

}

User Avatar

Wiki User

13y ago

What else can I help you with?

Continue Learning about Engineering

How do you write a c program to calculate the Fibonacci series of a given number?

To write a C program that calculates the Fibonacci series up to a given number, you can use a loop to generate the series. Start by initializing the first two Fibonacci numbers (0 and 1) and then repeatedly compute the next number by adding the two preceding numbers until you reach or exceed the specified limit. Here’s a simple example: #include &lt;stdio.h&gt; int main() { int n, t1 = 0, t2 = 1, nextTerm; printf(&quot;Enter a positive integer: &quot;); scanf(&quot;%d&quot;, &amp;n); printf(&quot;Fibonacci Series: %d, %d&quot;, t1, t2); for (int i = 3; i &lt;= n; ++i) { nextTerm = t1 + t2; printf(&quot;, %d&quot;, nextTerm); t1 = t2; t2 = nextTerm; } return 0; } This program prompts the user for a number and prints the Fibonacci series up to that number.


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


Can you explain the program of Fibonacci series in c?

You mean you have written a program, but you don't understand it? Well, how could I explain it without seeing it?


Do Fibonacci Series program in dot net?

public static int fib(int n) {return fib(n-1) + fib(n-2);}

Related Questions

Program to generate Fibonacci series using storage class in c plus plus?

i dn't know. haha


What is the assembly program to generate a geometric series and compute its sum The inputs are the base root and the length of the series The outputs are the series elements and their sum?

What is the assembly program to generate a geometric series and compute its sum The inputs are the base root and the length of the series The outputs are the series elements and their sum?


How do you generate Fibonacci series by adding previous three numbers?

subtract the smallest one


Create a c plus plus program to generate Fibonacci series?

#include #include void main() { clrscr() int a=0,b=1,c,i,n; coutn cout


How do you write a c program to calculate the Fibonacci series of a given number?

To write a C program that calculates the Fibonacci series up to a given number, you can use a loop to generate the series. Start by initializing the first two Fibonacci numbers (0 and 1) and then repeatedly compute the next number by adding the two preceding numbers until you reach or exceed the specified limit. Here’s a simple example: #include &lt;stdio.h&gt; int main() { int n, t1 = 0, t2 = 1, nextTerm; printf(&quot;Enter a positive integer: &quot;); scanf(&quot;%d&quot;, &amp;n); printf(&quot;Fibonacci Series: %d, %d&quot;, t1, t2); for (int i = 3; i &lt;= n; ++i) { nextTerm = t1 + t2; printf(&quot;, %d&quot;, nextTerm); t1 = t2; t2 = nextTerm; } return 0; } This program prompts the user for a number and prints the Fibonacci series up to that number.


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

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


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


Can you explain the program of Fibonacci series in c?

You mean you have written a program, but you don't understand it? Well, how could I explain it without seeing it?


Is 20 a Fibonacci number?

20 is not a term in the Fibonacci series.


What is the upper bound of the sum of the elements in the Fibonacci sequence?

There is no upper bound to the sum of the numbers in the Fibonacci sequence; both the last number in the series and consequently the sum of all these numbers can be made as large as desired by continuing the series to sufficiently many numbers.