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
monitta
4 years ago
6

Create a function that will return the nth Fibonacci Number where n is an integer passed as an argument. Demonstrate the functio

n in a program.
Computers and Technology
1 answer:
jek_recluse [69]4 years ago
7 0

Answer:

Here is code in C++.

// include header

#include<bits/stdc++.h>

using namespace std;

// function to calculate the nth Fibonacci term

int nth_fib(int num)

{   // base case for the recursive function

if (num <= 1)

 return num;

 // calculate the Fibonacci term by adding last two term of the sequence

return nth_fib(num-1) + nth_fib(num-2);

}

int main ()

{

   // variable to read term

int num;

cout<<"Please Enter the number: ";

cin>>num;

// calling the function to return the nth term of Fibonacci sequence

cout <<"The "<<num<<"th Fibonacci term is: "<<nth_fib(num);

 

return 0;

}

Explanation:

Declare a variable "num" to read the term. Call the function nth_fib() with parameter "num"; .In the nth_fib(),if num is less or equal to 1 then it will return(base case of recursive function).Otherwise it will calculate the Fibonacci term by adding the previous two terms. When it reaches to base condition, The function will return the nth term of sequence.

Output:

Please Enter the number:6

The 6th Fibonacci term is: 8

You might be interested in
Which website is important for hacking
Yuliya22 [10]

Answer:

Here's a few

Explanation:

  • SQL Injection attacks. SQL Injection attack is the most common website hacking technique. ...
  • Cross Site Scripting (XSS) ...
  • Denial of Service (DoS/DDoS) ...
  • Cross-site request forgery (CSRF or XSRF) ...
  • DNS Spoofing (DNS cache poisoning) ...
  • Social engineering techniques.

Glad I could help!!

6 0
3 years ago
______is a multimodal application software platform. the centrealized and shared database system ties the entire organization to
m_a_m_a [10]

Answer:

ERP.  

Explanation:

Enterprise Resource Planning Is the software platform for bidirectional applications. The main objective of  ERP it shared the database system and connects the enterprise as a whole so that data can be reached the once and made accessible to all users.

The main advantage of Enterprise Resource Planning is that Enterprise cycle parallelization or optimization it also the boost performance of the organization and saving the time.

3 0
3 years ago
Siltstone is made mostly of _____.<br><br> A : silt<br> B : sand<br> C : shells<br> D : gravel
frez [133]
The best and most correct answer among the choices provided by the question is the second choice. <span>Siltstone is made mostly of silt. </span>I hope my answer has come to your help. God bless and have a nice day ahead!
6 0
4 years ago
Read 2 more answers
What is one way you might code-switch when posting a comment to a class discussion?
irina [24]

Answer:

The term code switching has been expanded and can encapsulate in any situation that speaker find to be switch from vocabulary.

Explanation:

It is a truly remarkable skill when you communicate your emotions, thoughts and opinion to others. It does not mean that we just to communicate our language but our language influence our thought, emotions and language and self identity.

we communicate our culture that is reflected in our language. Our language tells that who we are and from where we comes.

Code switching is related to the speakers alternates use of multiple language. in the one communication.

For example: Grace for beautiful gift ( Esta awesome).

7 0
3 years ago
What is curated content?
disa [49]

Answer:

Content from the web that has been sorted through and shared on a brand’s digital platforms.

Explanation:

This type of content is created by other organizations but shared by a brand because they believe it will be of interest to their audience.

RIP 999

6 0
3 years ago
Other questions:
  • If a gas gosts 3.60 per gallon how much doe sit cost to drive 500 miles in the city
    5·1 answer
  • What kind of game was Pole Position?
    14·1 answer
  • A U.S. social security number consists of a string of 9 digits, such as "444422333". Declare a char array named ssn suitable for
    5·1 answer
  • A quick boot allows you to do what?
    7·2 answers
  • The it department is reporting that a company web server is receiving an abnormally high number of web page requests from differ
    13·1 answer
  • Write a MARIE program to allow the user to input 8 integers (positive, negative, or zero) and then find the smallest and the lar
    15·1 answer
  • What is the formula equivalent to the function =SUM(B1:B5)? A. =B1+B5 B. =$B$1+$B$5 C. =B1+B2+B3+B4+B5 D. =$B$1+$B$2+$B$3+$B$4+$
    7·1 answer
  • Abusive behavior, which involves the use of an electronic communications device, that is degrading, humiliating, hurtful, insult
    14·1 answer
  • 6. The following is a dump of a DATA chunk in hexadecimal format. 00000015 00000005 0003000A 00000000 48656C6C 6F000000 a. Is th
    7·1 answer
  • ANYONE WANNA FRIEND ME ON DISCORD ゴRose joestarゴ#2088
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!