Question

in c++ 1)Recursion occurs when a function's statements include a call to the function itself. There's...

in c++

1)Recursion occurs when a function's statements include a call to the function itself. There's no particular difference in how the parameters are defined.

A)True

B)False

2)Indicate whether the relationship of the following everyday item is an is-a or has-a relationship:

(True or False) Camera / Lens is a is-a relationship.

A)True

B)False

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1. True, the parameters are defined in the same way. However they are always called differently inside the recursive functions that is the values of the parameters are different.

For example:

In a program for calculating the factorial of a number using recursion, the function is defined as:

int factorial(int num)

{

if (num > 1)

return n*factorial(num - 1); // the program would fall in an infinite loop if that -1 is not there

else

return 1;

}

2. False. Camera has a lens. Camera isn't a lens.

Is-a relationships are defined by inheritance. For example: Dog is an Animal. Potato is a vegetable.

Has-a relationships are defined by composition. For example: A motorbike has an engine.

Add a comment
Know the answer?
Add Answer to:
in c++ 1)Recursion occurs when a function's statements include a call to the function itself. There's...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1. Write a recursive function that returns the sum of all even integers in a LinkedBinaryTree. Yo...

    please explain each line of code! ( in python ) 1. Write a recursive function that returns the sum of all even integers in a LinkedBinaryTree. Your function should take one parameter, root node. You may assume that the tree only contains integers. You may not call any methods from the LinkedBinaryTree class. Specifically, you should traverse the tree in your function def binary tree even sum (root): Returns the sum of al1 even integers in the binary tree 2....

  • 1. A(n) ____________________ is a variable or expression listed in a call to a function. 2....

    1. A(n) ____________________ is a variable or expression listed in a call to a function. 2. The pass by ____________________ mechanism must be used if the calling code is to receive information back from the function. 3. True or False? If there are several items in a parameter list, the compiler matches the parameters and arguments by their relative positions in the parameter and argument lists. 4. True or False? In C++, a function definition may have another function definition...

  • LANGUAGE IS C++ Lab Ch14 Recursion In this lab, you are provided with startup code which...

    LANGUAGE IS C++ Lab Ch14 Recursion In this lab, you are provided with startup code which has six working functions that use looping (for, while, or do loops) to repeat the same set of statements multiple times. You will create six equivalent functions that use recursion instead of looping. Although looping and recursion can be interchanged, for many problems, recursion is easier and more elegant. Like loops, recursion must ALWAYS contain a condition; otherwise, you have an infinite recursion (or...

  • A java program for this question please! Recursion: A word is considered elfish if it contains...

    A java program for this question please! Recursion: A word is considered elfish if it contains the letters: e, l, and f in it, in any order. For example, we would say that the following words are elfish: whiteleaf, tasteful, unfriendly, and waffles, because they each contain those letters. Write a recursive method called elfish(), that, given a word, tells us whether or not that word is elfish. The signature of the method should be: public static boolean elfish(String word)...

  • 1) In the XPath data model, a root node represents _______________? a) the document itself b)...

    1) In the XPath data model, a root node represents _______________? a) the document itself b) all within the XML declaration c) all the information within a particular namespace d) the root element 2) What is not a valid XPath data model node? a) Element b) Root c) Attribute d) Text e) Document type declaration 3) which of the following lines is the abbreviated syntax of attribute::attributename? a) %Cattributame b) &attributename c) @attributename d) #attributename 4) Axes are used to...

  • absolute C++ QUESTION 1 Which statement is incorrect? When an event occurs that cannot be managed...

    absolute C++ QUESTION 1 Which statement is incorrect? When an event occurs that cannot be managed locally, an exception may be thrown. Throwing the exception object transfers control and information gleaned locally to some calling program unit that manages the event, or the program terminates If an exception is thrown in a function, sayf, but not handled there, the exception is propagated to the function that called fo In C++, an exception object can be a user-defined type or any...

  • In Java Which of the following statements declares Salaried as a subclass of payType? Public class...

    In Java Which of the following statements declares Salaried as a subclass of payType? Public class Salaried implements PayType Public class Salaried derivedFrom(payType) Public class PayType derives Salaried Public class Salaried extends PayType If a method in a subclass has the same signature as a method in the superclass, the subclass method overrides the superclass method. False True When a subclass overloads a superclass method………. Only the subclass method may be called with a subclass object Only the superclass method...

  • 1. Ferrous metals include which of the following A Aluminum B. Copper C Gold D. Steel...

    1. Ferrous metals include which of the following A Aluminum B. Copper C Gold D. Steel 2. The two categories of metals that are based onion (Fe) are A Aluminum Alloy & Castle B. Chromium & Nickel C. Manganese & Vanadium D. Cast Iron & Steel 3. Aluminum Alloy, Nickel Alloy, Zinc Alloy, and Titanium Alloy are cumples of A Nonferrous Metals B.Ceramics C Superllos D. Carmets 4. In the heating of most metal alloys melting begins at a certain...

  • QUESTION 1 Which statement results in the value false? The value of count is 0; limit...

    QUESTION 1 Which statement results in the value false? The value of count is 0; limit is 10. (count != 0)&&(limit < 20) (count == 0)&&(limit < 20) (count != 0)||(limit < 20) (count == 0)&&(limit < 20) 10 points    QUESTION 2 If this code fragment were executed in an otherwise correct and complete program, what would the output be? int a = 3, b = 2, c = 5 if (a > b) a = 4; if (...

  • Need help problem 9-13 C++ Homework please help WRITE FUNCTION PROTOTYPES for the following functions. The...

    Need help problem 9-13 C++ Homework please help WRITE FUNCTION PROTOTYPES for the following functions. The functions are described below on page 2. (Just write the prototypes) When necessary, use the variables declared below in maino. mm 1.) showMenu m2.) getChoice 3.) calcResult m.) showResult 5.) getInfo mm.) showName 7.) calcSquare 8.) ispositive int main { USE THESE VARIABLES, when needed, to write function prototypes (#1 - #8) double num1 = 1.5; double num2 = 2.5; char choice; double result;...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT