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

what mean actual with English ​
what is the formula for a progressive wave.​
create a political cartoon that shows why casework is such an important aspect of being an effective legislator
Select the correct answer. What design feature of the Hagia Sophia was considered daring? A. the two half domes extending from the main dome. B. the main do
What is the measurement of LaTeX: \angle Z
The lion gave a roar that echoed down the valley. Does this sentence contain personification? Explain your answer.
3. Why are people with anorexia unlikely to ask for help?.
How to write a tbq question (the format)
Who suggested that a person’s physical characteristics could predict whether they were a criminal or not? A. Emile durkheim B. Hans J. Eysenck C. Cesare lombro
Which statement best defines childbirth? O A. The process by which the uterus contracts to push the fetus out of the woman's body through the vagina O B. The pe