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

1. What is likely to be caused by a diet low in both fat and fibre?A. Constipation and obesityB. Constipation onlyC. Neither constipation nor obesityD. Obesity
A. Identify the type of molecule shown in the drawing. (2 points)
Help please due today
A spinner with five equal-sized colored sections is spun with the results shown in the table. Based on the experimental probability, predict the number of green
When is the pressure of the man on the ground more – lying position or standing position? Explain.
Simplify each expression completely.7[3+2(x-4)-6(x-4)]
I will crown you! And extra points! Just need some help on this question.
Free Have A Good Day
I need help I don’t understand this at all
porque los mexicas eran un imperio