63 125
Assignments Done
99%
Successfully Done
In July 2018

Answer to Question #57833 in C++ for Ali hassan

Question #57833

write a program that inputs a number from the user and displays fibonacci series up to the number entered
Expert's answer
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!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions