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

Where do I put the parentheses so the result matches the answer
How do you use bumptious in two sentences ?
What did those who favored the newly proposed stronger national government choose to call themselves?
which type of historical text typically focuses on a particular topic, Integrating primary and secondary source documents to advance and argument
what is 89+27+11 using a mental math property
Describe Madame Loisel at the beginning of the sorry? Analyze her using her details from the story. Explain what is important to her and what makes you think so
Which expression is equivalent to 9(15)? 9(1 + 5) 9(10 + 5) 9(1 + 50) 9(10 + 50)
Write the molecular balanced chemical equation and the net ionic equation for the reaction between ca(oh)2 and hcl
Mike bungee jump from a building with eight stories each story was 15 4/5 feet in height how tall is the building
What's the answer? I need help!