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
Serga [27]
3 years ago
9

Write an application program in C++ to implement a class Fibonacci to print Fibonacci series upto N using member function series

() .
​

Computers and Technology
1 answer:
fiasKO [112]3 years ago
5 0

Answer:

Program approach:-

  • Using the header file.
  • Using the standard namespace I/O.
  • Define the main function.
  • Display the number of terms.
  • Display the Fibonacci series.
  • Print the first two numbers.

Explanation:

Program:-

//header file

#include <iostream>

//using namespace

using namespace std;

//main function

int main() {

   int n, s1 = 0, s2 = 1, nextTerm = 0;

//display the number of terms

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

   cin >> n;

//display the Fibonacci series

   cout << "Fibonacci Series: ";

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

       // Prints the first two terms.

       if(j == 1) {

           cout << s1 << ", ";

           continue;

       }

       if(j == 2) {

           cout << s2 << ", ";

           continue;

       }

       nextTerm = s1 + s2;

       s1 = s2;

       s2 = nextTerm;

       

       cout << nextTerm << ", ";

   }

You might be interested in
Write a program that will print out statistics for eight coin tosses. The user will input either an "h" for heads or a "t" for t
shusha [124]

Answer:

Written in Python

head = 0

tail = 0

for i in range(1,9):

     print("Toss "+str(i)+": ")

     toss = input()

     if(toss == 'h'):

           head = head + 1

     else:

           tail = tail + 1

print("Number of head: "+str(head))

print("Number of tail: "+str(tail))

print("Percent head: "+str(head * 100/8))

print("Percent tail: "+str(tail * 100/8))

Explanation:

The next two lines initialize head and tail to 0, respectively

head = 0

tail = 0

The following is an iteration for 1 to 8

<em>for i in range(1,9): </em>

<em>      print("Toss "+str(i)+": ") </em>

<em>      toss = input()  </em><em>This line gets user input</em>

<em>      if(toss == 'h'):  </em><em>This line checks if input is h</em>

<em>            head = head + 1 </em>

<em>      else:  </em><em>This line checks otherwise</em>

<em>            tail = tail + 1 </em>

The next two lines print the number of heads and tails respectively

print("Number of head: "+str(head))

print("Number of tail: "+str(tail))

The next two lines print the percentage of heads and tails respectively

print("Percent head: "+str(head * 100/8))

print("Percent tail: "+str(tail * 100/8))

3 0
3 years ago
Sami is creating a web page for her dog walking business. Which item will set the theme for her page? Background color Heading c
bazaltina [42]

Answer:

A Background color

Explanation:

7 0
3 years ago
For some people , alcohol can cause an uncontrollable blank of the eyes , making good vision almost impossible
ss7ja [257]
The statement above wil be completed.

For some people, alcohol can cause an uncontrollable vibration to the eyes, making good vision almost impossible. This vibration is called nystagmus or the eyes getting dizzy and shaky. This nystagmus occurs when a person drinks too much and reaches his limit in alcohol intake.
7 0
3 years ago
What is faster C++ or go lang
alukav5142 [94]

Answer:

C++

Explanation:

3 0
3 years ago
What is the easiest way to be sure you have selected all of the content related to a specific tag?
pychu [463]
Add a <div> around it.
example:
<div id = "content">
<p> content</p>
</div>
4 0
3 years ago
Other questions:
  • Selecting the option to control Widows and Orphans will prevent _________. A single line from appearing at the top or bottom of
    10·1 answer
  • Strong emotions can interfere with your ability to
    15·1 answer
  • Within the Chart Design tab, which section is used to change the data of a previously created chart?
    12·1 answer
  • Given the code segment below, complete the assignments as stated in the comments. struct aaa { int m; int nn; } struct bbb{ stru
    13·1 answer
  • Given the availability of an ofstream object named output, write the other statements necessary to write the string "3.14159" in
    8·1 answer
  • Make me die from laughter i will give brainlyest for the best joke
    11·1 answer
  • A town government is designing a new bus system. The planners are deciding where to put the different bus stops. They want to pi
    6·2 answers
  • What<br>are<br>the features of secondary storage media​
    13·2 answers
  • What does advance mean​
    6·1 answer
  • A small business named Widgets, Inc. has hired you to evaluate their wireless network security practices. As you analyze their f
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!