answersLogoWhite

0

Wap to display the Fibonacci series?

Updated: 12/21/2022
User Avatar

Wiki User

14y ago

Best Answer

#include<stdio.h>

main()

{

int a=0,b=1,n,c,i;

printf("enter number");

scanf("%d",&n);

printf("%d\n",a);

for(i=1;i<=n;i++)

{

c=a+b;

printf("%d\n",c);

b=a;

a=c;

}

getch();

}

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Wap to display the Fibonacci series?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Fibbomacci series using recursion shell programming?

Here is a good answer for recursion Fibonacci series. #include &lt;stdio.h&gt; #include &lt;conio.h&gt; long Fibonacci(long n); int main() { long r, n,i; printf("Enter the value of n: "); scanf("%ld",&amp;n); for(i=0;i&lt;=n;i++) { printf(" Fibonacci(%ld)= %ld\n", i,Fibonacci(i)); } getch(); return 0; } long Fibonacci(long n) { if(n==0 n==1) return n; else { return (Fibonacci(n-1)+Fibonacci(n-2)); } } for n=5; Output: Fibonacci(0)=0 Fibonacci(1)=1 Fibonacci(2)=1 Fibonacci(3)=2 Fibonacci(4)=3 Fibonacci(5)=5


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


What is the importance of the Fibonacci series?

The Importance of Fibonacci's series is that it helps people find more patterns 1+0=1 1+1=2 1+2=3 2+3=5 5+3=8 etc.


Write a cobol pgm to find the Fibonacci series?

Identification division. Program-id. Fibonacci. Environment division. Data division. Working-storage section. 77 n pic 9(18). 77 n1 pic z(18). 77 m pic 9(18) value 1. 77 o pic 9(18). 77 i pic 9(4) value 1. 77 q pic x. Procedure division. Para-a. Display ( 1 , 1 ) erase. Display ( 2 , 1 ) "fibonacci numbers from 1 to 100 are:". Move 0 to n. Display " ". Display 0. Display 1. Move 0 to o. Para-b. Compute n = o + m. Move n to n1. Move m to o. Move n to m. Display n1. Add 1 to i. If i = 21 display "press tab key to view next page." accept q. If i = 41 display "press tab key to view next page." accept q. If i = 61 display "press tab key to view next page." accept q. If i = 81 display "press tab key to view next page." accept q if i = 99 go to stop-para else go to para-b. Stop-para. Display " ". Stop run.


Write a program to print the Fibonacci series in php upto input value using recursive function?

The Fibonacci sequence uses recursion to derive answers. It is defined as: F0 = 0 F1 = 1 Fn = F(n - 1) + F(n -2) To have this sequence printed by a php script use the following: function fibonacci($n) { if($n 1) return 1; //F1 else return fibonacci($n - 1) + fibonacci($n - 2); //Fn } This recursive function will print out the Fibonacci number for the integer n. To make it print out all the numbers in a particular set add this to your script. for($i = 0; $i &lt; 15; $i++) { echo fibonacci($i) . "&lt;br /&gt;"; } So your final result would look like. &lt;?php function fibonacci($n) { if($n 1) return 1; else return fibonacci($n - 1) + fibonacci($n - 2); } for($i = 0; $i &lt; 15; $i++) { echo fibonacci($i) . "&lt;br /&gt;"; } ?&gt;