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

Which of the following structure is a tissue? Vessel element,sieve tube element, erythrocyte and blood
describe two ways you can use a table to write a proportion
[(8 + 10) ÷ 3] + 3 • (7 - 3) equals?
2miles less than 3333yards
What are some of your thoughts about the life of Mary Shelley, the events that happened in her novel, and its themes such as parental responsibilities (or creat
Mollusks' group of organs is called a
Lalo has 1500 minutes per month on his cell phone plan. how many more minutes can he use if he has already talked for 785 minutes?
Does anybody now anything about World War I plus I need notes?
Hugh bought some magazines that cost $3.95 each and some books that cost $8.95 each. He spent a total of $47.65. If Hugh bought 3 magazines, how many books did
a high speed train travels south for 2.00 h for a distance of 454 km. what is its average velocity?