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

You fill a balloon with 2.50 moles of gas at 25°C at a pressure of 1.49 atm. What is the volume of the balloon?
What is a synonmyn for coat
What is 1280 billion devided by 47.9%
3 and 1/4 times -2 and 3/5? Answers: A. -8 9/20 B. -6  and 3/20 C. 6 and 3/20 D. 8 and 9/20
A rectangular room is 6 yards long an 12 feet wide.  Find the perimeter in feet.  Then find the perimeter in yards.
Why does Nick seem to disapprove of Gatsby's wealth and status in the book the great gatsby?
use substitution to solve the sytem: 5x-3y=-20 and x=3y-16
put the rainfall measurements in order from least to greatest.0.97 meters0.947 meters1.5 meters1.268 meters
How did Great Britain threaten manifest destiny
Which kind of bonds are most easily broken in water? a. ionic b. peptide c. disulphide d. single covalent e. double covalent