Answer to Question #57833 in C++ for Ali hassan
write a program that inputs a number from the user and displays fibonacci series up to the number entered
1
2016-02-17T05:37:29-0500
Answer on Question#57833 — Programming | C++
#include <iostream>
using namespace std;
int main() {
int n, first = 0, second = 1, next = 1;
cin >> n;
if (n > 1) cout << 1 << endl;
while (next < n) {
next = first + second;
first = second;
second = next;
if (next < n) cout << next << endl;
}
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Learn more about our help with Assignments:
C++
Comments
Leave a comment