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

Write your own real-world scenario where the Pythagorean Theorem can be applied to find a missing piece. You may choose to write a problem that is two- or three
Which two auto companies received help from the US government during the crisis of 2008?
Who led the first attempt to create a canal through central america to connect the atlantic and pacific oceans and what country was he from?
How can you tell if a number is a rational or irrational
A solution is prepared by dissolving 17.75 g sulfuric acid, h2so4, in enough water to make 100.0 ml of solution. if the density of the solution is 1.1094 g/ml,
Factors giving rise to the theories of Marx included: abuses dealt to the working class understanding bosses poor conditions under which laborers lived and
According to Freytag’s Pyramid, what stage comes directly after the climax? exposition denouement resolution rising action
How do odd-shaped ceilings, decorative panels, draperies, and glass windows affect echo and noise?
math help again please
If 8 ties cost $128, how much do 15 ties cost?