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
geniusboy [140]
3 years ago
8

Give a recursive algorithm for finding the sum of the first n odd positive integers.

Computers and Technology
1 answer:
Andrei [34K]3 years ago
3 0
I'm writing that in some sort of pseudocode; if you don't understand it, feel free to ask for more details in the comments.

function sumOdd(n)
    if n==1 then
        return 1
    end if
    return (sumOdd(n-1))+(n*2-1)
end function
You might be interested in
In Python please:
Sauron [17]

Answer:

import math

angle = float(input('Enter Angle: '))

shadowLength = float5(input('Enter Shadow Length: '))

tree_height = math.tan(angle)*shadowLength

print('Tree Height = {}'.format(tree_height))

Explanation:

From the equation given, the first step is to derive the equation for calculating the Tree Height.

tan(angleElevation) = tree height / shadow length\\\\tree height = tan(angleElevation) * shadow length

In order to calculate the tangent of an angle, the math module has to be imported. math module allows the program to perform advanced math operations.

The program then prompts the user to input values for angle and shadow length.

The inputted values are converted to floats and used in the equation that was derived for Tree height.

Three height is evaluated and the result is printed to the screen

4 0
3 years ago
27. List four advantages of Computer Aided Design over traditional hand
tatyana61 [14]

Decrease in error CAD software makes use of some of the best tools, the percentage of error that occurred because of manual designing is significantly reduced.

Decrease in effort when it comes to the amount of effort that was needed for the sake of designing the different models, it has been reduced significantly because the software automates most of the task.

Saves time when you are using the computer aided design software, it will save your time and you can make better and more efficient designs in shorter time duration.

Easy to edit when you are making designs, you may find the need to make alterations. When you are using computer aided design software, it will be much easier to make any changes because you can fix the errors and modify the drawings easily.

8 0
3 years ago
In which of the following situations may the taxpayer take an education expense on Schedule C? a. Henry, a self-employed adminis
daser333 [38]

Answer:

Henry, an administrative assistant, is taking an advanced Word computer program class through an adult school program.  

Explanation:

4 0
3 years ago
an engineer is writing a web application that requires some user input. the engineer has put a submit button on their page and n
Setler [38]

In order to make the program recognize the clicking of a button, the engineer should add an event listener to the JavaScript code.

An event is considered to be a vital part of JavaScript because a web page responds according to the event that occurred. Some events are generated by APIs and some are user-generated events. For example, clicking or moving the mouse button and pressing a key on the keyboard are user generated events.

In order to handle the user-generated events in JavaScript,  an event listener is used. An event listener is a function or procedure in a JavaScript program that waits for an event to occur; such as pressing a key on the keyboard or clicking the button. Therefore based on the scenario given in the question statement, the engineer should use an event listener to his JavaScript code so that the code can recognize the click of the button.

You can learnmore about event at

brainly.com/question/20169706

#SPJ4

7 0
10 months ago
Write a destructor for the CarCounter class that outputs the following. End with newline.
ycow [4]

Answer:

Following are the code to this question:

CarCounter::~CarCounter()//Defining destructor CarCounter

{

cout << "Destroying CarCounter\n";//print message Destroying CarCounter

}

Explanation:

Following are the full program to this question:

#include <iostream>//Defining header file

using namespace std;

class CarCounter //Defining class CarCounter

{

public:

CarCounter();//Defining constructor CarCounter

~CarCounter();//Defining destructor CarCounter

private:

int carCount;//Defining integer variable carCount

};

CarCounter::CarCounter()//declaring constructor  

{

carCount = 0;//assign value in carCount variable

return;//using return keyword

}

CarCounter::~CarCounter()//Defining destructor CarCounter

{

cout << "Destroying CarCounter\n";//print message Destroying CarCounter

}

int main() //Defining main method

{

CarCounter* parkingLot = new CarCounter();//Defining class object parkingLot

delete parkingLot;//

return 0;

}

  • In the given C++ language code, a class "CarCounter" is defined, and inside the class, a "constructor, Destructors, and an integer variable" is defined.  
  • Outside the class, the scope resolution operator is used to define the constructor and assign value "0" in the integer variable.  
  • In the above-given code, the scope resolution operator, to define destructor and inside this cout function is used, which prints a message.  
  • In the main method, the class object is created, which automatically calls its class constructor and destructors.  
7 0
3 years ago
Other questions:
  • Which disk drive type contains a magnetic HDD with onboard flash memory serving as a non-volatile cache?
    6·1 answer
  • Abram was asked to explain to one of his coworkers the XOR cipher. He showed his coworker an example of adding two bits, 1 and 1
    7·1 answer
  • Recording music using a keyboard controller is commonly accomplished using which type of audio file format?
    13·1 answer
  • Free brainliest hehehehehehehheheh
    13·2 answers
  • 9. Which of the following is the<br>leading use of computer?​
    13·1 answer
  • If you wanted to make the system sequentially consistent, what are the key constrains you need to impose
    6·1 answer
  • If you forget your privacy password what will you do if the ask this question what is the name of one of your teacher?​
    12·1 answer
  • Assume that x and y are boolean variables and have been properly initialized. !(x || y) || (x || y) The result of evaluating the
    10·1 answer
  • The success criteria are used to judge whether a project is successful. False True <br> need it now
    13·2 answers
  • What is an advantage of using a fully integrated cloud based data analytics platform
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!