Question

In: Computer Science

Your manager asked you to generate a Fibonacci sequence to be used in a data analysis...

Your manager asked you to generate a Fibonacci sequence to be used in a data analysis project. The Fibonacci sequence is a series of numbers in which the next number is found by adding up the two numbers before it (e.g., 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ...).

Write a C++ program to generate a Fibonacci sequence of the first 20 numbers.

Solutions

Expert Solution

CODE:

#include<iostream>
using namespace std;
int main()
{
int a = 0, b = 1;//declaring initial values.
int c;//next number of series.
cout<<"The fibonocci series is : "<<a<<", "<<b;
//we iterate 20 times to generate 20 numbers.
for(int i= 0 ; i < 20 ;i++)
{
c = a + b;//adding before 2 numbers to get next number.
a = b;//changing a to b.
b = c;//changing b to c.
cout << ", "<< c;//printing the next number.
}
}
CODE ATTACHMENTS:

OUTPUT:

Please do comment for any queries.
Please like it.
Thank you.


Related Solutions

A. Imagine you are a HRM manager and asked to do a job analysis for a...
A. Imagine you are a HRM manager and asked to do a job analysis for a job title at your company, choose any job title you know or hear about and make a job description and job specification. 10 marks B. Discuss and explain in your own words with relevant examples the “Marketing concept” 15 marks
Consider the Fibonacci sequence 1,1,2,3,5,8,13,21,34,55,89,…. . The first two numbers are 1 and 1. When you...
Consider the Fibonacci sequence 1,1,2,3,5,8,13,21,34,55,89,…. . The first two numbers are 1 and 1. When you add these numbers you get 2 = 1+1, which becomes the third number in the sequence. When you add the second and third numbers, you get 3 = 1+2, which becomes the fourth number in the sequence. When you add the third and fourth numbers, you get 5 = 2+3, which becomes the fifth number in the sequence; and so on to generate the...
Describe the approaches and techniques used to generate the first draft of the human genome sequence...
Describe the approaches and techniques used to generate the first draft of the human genome sequence in Feb 2001? 2 pages min with diagrams . thanks
Assume that you are a manager and your boss asked to meet with you later today...
Assume that you are a manager and your boss asked to meet with you later today to discuss putting a team together. Since you were not provided with any other information, you need to be prepared with a written document. Identify the different options for groups and teams, indicate when each type is appropriate, and include some of the characteristics of groups and teams. Also describe the stages of formation. Also, include some of the characteristics of groups and teams.
Your manager has asked you to put together a survey that you are to send to...
Your manager has asked you to put together a survey that you are to send to all employees regarding topics they would like to be trained on. Write at least 10 effective questions and add them to the survey Examples: What areas do you feel as though you have deficiencies within that you would benefit from additional training? What topics do your peers most frequently ask you questions regarding? These questions will be challenging to think of, but that is...
Assume that you are a manager in a factory and your supervisor has asked you increase...
Assume that you are a manager in a factory and your supervisor has asked you increase productivity without hiring additional workers or incurring overtime. Describe how you could motivate the existing workers using one content perspective and one process perspective. Support your answer.
Assume you are the accounting manager of Kitten Ltd. being asked from your senior manager to...
Assume you are the accounting manager of Kitten Ltd. being asked from your senior manager to prepare inventory records and compute the closing value of inventory, cost of manufacturing, and cost of goods sold to be reported in the Financial Statements. Following are the inventory related activities that were performed during the period. 1 Purchased 960 units @ 56 per unit 2 Purchased 420 units @54 per unit 3 Issued 280 units to the manufacturing department 4 Manufacturing department worked...
Implement in a computer the curve fitting. Generate appropriate data for your implementation (e.g., generate data...
Implement in a computer the curve fitting. Generate appropriate data for your implementation (e.g., generate data from a polynomial function and add noise with variance σ2). Show the mean square error of the estimator in your implementation. What can you say about under/over fitting (that is, when the degree of your approximator is too small or too large for your data).
Suppose you are an investment analyst, your supervisor, a portfolio manager asked you to write a...
Suppose you are an investment analyst, your supervisor, a portfolio manager asked you to write a brief report on how will the COVID-19 outbreak affect the stock market and economy in the world and Malaysia, and the report must include detailed analysis from part (1) to part (3) below. Perform a fundamental analysis of the overall market and economy in Malaysia. How will COVID-19 outbreaks across the world affect the Malaysian economy in terms of economic growth rate in 2021?...
After finishing your risk management course, you are asked by your portfolio manager to calculate the...
After finishing your risk management course, you are asked by your portfolio manager to calculate the VaR of the portfolio that is consisting of two asset classes: long-term government bonds issued in the United States and long-term government bonds issued in the United Kingdom. The expected monthly return on US bonds is 0.85% and the standard deviation is 3.20%, while the expected monthly return on UK bonds (in US dollars) is 0.95% and the standard deviation is 5.26%. The correlation...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT