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

120, 160, 200 Find the gcfplease show me the work.
who is martin Luther king
A 170 g hockey puck sliding at 25 m/s slows to a speed of 10 m/s in a distance of 7.5 m.  Determine the force of friction causing the puck to slow.
Which of the following is equivalent to 6x 2 + x - 12 ? A. (2x + 3)(3x - 4) B. (2x - 3)(3x - 4) C. (2x + 3)(3x + 4) D. (6x + 3)(x - 12) E. (x + 3)(2x - 12) Plea
1. Explain with reasons why burning of paper is a chemical change.
How much is 22 percent of 200 gallons? 37 meters is 74 percent of what distance?
How much is 22 percent of 200 gallons? 37 meters is 74 percent of what distance?
C+(4-3c)-2=0 Need help
explain the advantages of crystallisation over evaporation
How much is 22 percent of 200 gallons? 37 meters is 74 percent of what distance?