Answer to Question #283664 in C++ for Jen

Question #283664

Write a program that will ask a user to input a number n. The program will then display a 

Fibonacci sequence with n as number of displayed sequence. 



1
Expert's answer
2021-12-30T07:14:12-0500

#include <iostream>

using namespace std;

int main()

{

  int sum=0, n;

  int a=0;

  int b=1;

  cout<<"Enter the nth value ";

  cin>>n;

  cout<<"Fibonacci series="<<endl;

  while(sum <= n)

{

 cout<<sum;

 

a = b;

b = sum;

sum = a + b; 

}

return 0;

 }

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 the first!

Leave a comment

LATEST TUTORIALS
New on Blog