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
zhuklara [117]
3 years ago
13

Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 te

rms will be:
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...

a term index is entered and Fibonacci sequence is calculated up to that term.

If the index is 5 then the sequence is : 0, 1, 1, 2, 3

if the index is 7 then the sequence is : 0, 1, 1, 2, 3, 5, 8

Write a program that will print the Fibonacci sequence to the term index entered by the user.

The program will ask you if you want to print another sequence; if Yes repeat if No end your program
Computers and Technology
1 answer:
AlexFokin [52]3 years ago
3 0

//C++:

#include <iostream>

#include <string.h>

using namespace std;

int F(int n) {

 if(n == 0) {

   return 0;

 }

 if(n == 1) {

   return 1;

 }

 else  

   return F(n-1) + F(n-2);

 }

int main()

{

   int index;

   int ok=0;

   char x[3];

   do{

   cout<<"index=";cin>>index;

   for(int i=0;i<index;i++)

   cout<<F(i)<<' ';

   cout<<endl;

   cout<<"Repeat? (Yes/No):";

   cin>>x;

   if(strcmp(x,"No")==0)

   ok=1;

   cout<<endl;

   }while(ok==0);

   return 0;

}

You might be interested in
Write a program that reads in an array of type int . you may assume that there are fewer than 50 entries in the array. your prog
Alla [95]
This may be a difficult thing to do so for anyone to ACTUALLY answer this you migghttt want to up the amount of points you get for answering maybe, 20-40 points.
7 0
3 years ago
Type the correct answer in the box. Spell the words correctly.
ExtremeBDS [4]

Answer:

The IT field yeah am sure

7 0
3 years ago
Which of the following tasks are suitable for creating an algorithm? Choose all that apply.
Nookie1986 [14]

Answer:

All except saving time writing a computer program.

3 0
2 years ago
What is rss A)real time story service B) real time story syndication C) really simple syndicationD)rapid story services
Novosadov [1.4K]

C) Really Simple Syndication

4 0
3 years ago
The connectors on the computer allow you to plug in devices such as keyboards and printers. what are these called?
madam [21]
USB port. That allows you to plug in devices.
8 0
3 years ago
Other questions:
  • Which item refers to an illusion of figures and shapes in motion, which we commonly see in movies and video games?
    9·1 answer
  • Select all statements that correctly describe the ramifications of important features supported by modern DBMS.
    15·1 answer
  • Explain why professional software that is developed for a customer is not simply the programs that have been developed and deliv
    13·1 answer
  • A research team is studying parallel computing. They want to run parallel processes without having to use multiple processors. H
    15·2 answers
  • Determine the number of bytes necessary to store an uncompressed binary image of size 4000 × 3000 pixels
    11·1 answer
  • Select all that apply.
    10·1 answer
  • What is the purpose of using variables in programming?
    11·1 answer
  • Which tools is used to bundle cables neatly inside and outside of a computer?​
    15·1 answer
  • Calculate the resistance of an unknown resistor in a circuit with 30 volts and 6 amps. The formula is R = V/I.
    6·1 answer
  • Write a program to compute the maximum and minimum value of three numbers:
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!