ItsMoonLight6366 ItsMoonLight6366
  • 22-01-2021
  • Computers and Technology
contestada

Write a c++ programm that enter a number from the user and displays Fibonacci numbers from 1 to given number using function

Respuesta :

tonb
tonb tonb
  • 22-01-2021

Answer:

#include <iostream>

using namespace std;

int main()

{

   cout << "Enter number: ";

   int number;

   cin >> number;

   int prevfib = 0;

   int fib = 1;

   while (fib <= number) {

       cout << fib << " ";

       int add = prevfib;

       prevfib = fib;

       fib += add;

   }

}

Answer Link

Otras preguntas

How many moles of sodium hydroxide are produced when 1.00 mol sodium peroxide reacts with water
the area of a sector of the circle with an arc measure of 45 degree and with a radius of 4 is?
What does karyote mean?
When organisms must compete for resources, they will usually have a ____________ distribution. a. uniform b. random c. clumped d. competitive
what word best describe chlorophyll
How many miles did the the russian empire stretch from east to west in 1861
How did the booming economy of the 1920s lead to changes in American life?
Which sentence does not contain any punctuation errors?  A.The smoothie recipe includes the following, frozen berries, yogurt, and vanilla extract.  B.The smoot
How did America end up going to War with Iraq?
Maria is tossing a fair coin. She tosses the coin ten times and it lands on heads eight times. If Maria tosses the coin an eleventh time, what is the probabilit