1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
sp2606 [1]
3 years ago
12

1- By using C++ programming language write a program which displays the Fibonacci Series numbers. Note: The number of elements i

s taken as in input from the user Hint: The Fibonacci Sequence: 0,1,1,2,3,5,8,13,21,34,55.. .
Computers and Technology
1 answer:
dedylja [7]3 years ago
3 0

Answer:

i hope this helpful for you

Explanation:

Example 1.

#include <iostream>

using namespace std;

int main() {

   int n, t1 = 0, t2 = 1, nextTerm = 0;

   cout << "Enter the number of terms: ";

   cin >> n;

   cout << "Fibonacci Series: ";

   for (int i = 1; i <= n; ++i) {

       // Prints the first two terms.

       if(i == 1) {

           cout << t1 << ", ";

           continue;

       }

       if(i == 2) {

           cout << t2 << ", ";

           continue;

       }

       nextTerm = t1 + t2;

       t1 = t2;

       t2 = nextTerm;

       

       cout << nextTerm << ", ";

   }

   return 0;

}

Example 2.

#include <iostream>

using namespace std;

int main() {

   int t1 = 0, t2 = 1, nextTerm = 0, n;

   cout << "Enter a positive number: ";

   cin >> n;

   // displays the first two terms which is always 0 and 1

   cout << "Fibonacci Series: " << t1 << ", " << t2 << ", ";

   nextTerm = t1 + t2;

   while(nextTerm <= n) {

       cout << nextTerm << ", ";

       t1 = t2;

       t2 = nextTerm;

       nextTerm = t1 + t2;

   }

   return 0;

}

You might be interested in
Mary can view the thumbnails of her presentation slides when she’s creating the slides which element of the programs interface i
zubka84 [21]

Answer:

Slide panel is the correct answer.

Explanation:

4 0
3 years ago
A function ________ contains the statements that make up the function.
mestny [16]

Answer:

A) definition

Explanation:

3 0
3 years ago
Bob received a message from Alice which she signed using a digital signature. Which key does Bob use to verify the signature?Gro
alexira [117]

Answer:

Alice's public key

Explanation:A Public key is a key that can be used for verifying digital signatures generated using a corresponding private key which must have been sent to the user by the owner of the digital signature.

Public keys are made available to everyone required and they made up of long random numbers.

A digital signature signed with a person's private key can only be verified using the person's private key.

7 0
4 years ago
A well-diversified portfolio needs about 20-25 stocks from different categories is this True or False?
borishaifa [10]

Usually they hold 15-20 as the minimum of the portfolios

So I would say True

3 0
4 years ago
Read 2 more answers
Plz show working for binary addition. please solve. 11000 + 110101 + 101011​​
IrinaVladis [17]

Answer:

thats would be 222112 <3

Explanation:

t

5 0
3 years ago
Read 2 more answers
Other questions:
  • _____ software can help a company manage security, enforce corporate strategies, and control downloads and content streaming fro
    11·1 answer
  • Which of following allows you to share a file with someone that is too large to send via e-mail?
    5·1 answer
  • What is the purpose of exporting your public key to the directory services server?
    11·1 answer
  • What additional features on your router would you implement if you were setting up a small wired and wireless network
    5·1 answer
  • Write an Enlistee class that keeps data attributes for the following pieces of information: • Enlistee name • Enlistee number Ne
    7·1 answer
  • Manuel is working on a project in Visual Studio. He wants to keep this program showing on the entire desktop, but he also needs
    13·1 answer
  • Which of the following might an interior designer in the retail industry specialize in?
    9·1 answer
  • What is the purpose of extent in lines in engineering drawing
    12·1 answer
  • Write a program that simulates applying a "boost" to a spaceship in a spaceship race game.
    12·1 answer
  • Chantal has configured the network at her company's new headquarters with a number of VLANs. All devices joined to the individua
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!