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
blsea [12.9K]
3 years ago
7

X274: Recursion Programming Exercise: Cannonballs Spherical objects, such as cannonballs, can be stacked to form a pyramid with

one cannonball at the top, sitting on top of a square composed of four cannonballs, sitting on top of a square composed of nine cannonballs, and so forth.
RequireD:
Write a recursive function that takes as its argument the height of a pyramid of cannonballs and returns the number of cannonballs it contains.
Computers and Technology
1 answer:
Inga [223]3 years ago
3 0

Answer:

The function in C is as follows:

#include <stdio.h>

int C_ball(int height){

if(height == 1) {

       return 1;}

   return (height * height) + C_ball(height - 1);}      

int main(){

   int n;

   printf("Height: ");

   scanf("%d",&n);

   printf("Balls: %d",C_ball(n));

   return 0;

}

Explanation:

The function begins here

#include <stdio.h>

This defines the function

int C_ball(int height){

If height is 1, return 1

<em>if(height == 1) { </em>

<em>        return 1;}</em>  

This calls the function recursively

   return (height * height) + C_ball(height - 1);}

The main begins here

int main(){

This declares the height as integer

   int n;

This prompts the user for the height

<em>    printf("Height: "); </em>

<em>    scanf("%d",&n);</em>

This calls the function

   printf("Balls: %d",C_ball(n));

   return 0;

}

You might be interested in
Which of the following statements about interpreting colors are true? Select 3 options.
sukhopar [10]

Answer:

B, C and E

Explanation:

B :

White. In Western cultures, white symbolizes purity, elegance, peace, and cleanliness; brides traditionally wear white dresses at their weddings. But in China, Korea, and some other Asian countries, white represents death, mourning, and bad luck, and is traditionally worn at funerals.

C:

Color psychology has a effect for the world's different cultures. Colors evoke various emotions and beliefs, as well as positive and negative connotations. A color may represent happiness and warmth in one culture but is associated with betrayal and jealousy in another.

E:

Blue is one of the most commonly used colors in American marketing, often considered a safe color for a global audience, because it lacks significant negative connotations. Blue is tied to immortality, spirituality, and heaven in Eastern cultures.

Thank You! Please mark me brainliest!

Sorry if I'm wrong.

8 0
3 years ago
In “Plugged In,” the author’s purpose is to persuade. Which of the following quotes from the text shows that the author’s purpos
lisabon 2012 [21]

The quote from the text that shows that the author’s purpose is to persuade is D. Critics say that kids stare at computers and TVs all day and do not get enough exercise. The facts stand in counterpoint to this belief.

An argumentative writing prompt is written in order to convince the readers about a particular issue.

According to the author, the fact that children are involved in watching movies, playing games, listening to music, etc doesn't mean that they can't still be productive.

There are some critics that believe that kids stare at computers and TVs all day and do not get enough exercise. This was countered by the author who stated that kids can still engage in exercises or do other productive things.

Read related link on:

brainly.com/question/24861556

3 0
2 years ago
If a firm is set to use open-source software with which no one in the IT department is familiar, what should it do? fire the IT
Aleonysh [2.5K]
The most efficient thing to do would be to provide training as firing or doing nothing halts productivity indefinitely while training eventually will finish
7 0
3 years ago
Read 2 more answers
Bertha was recording a drama club practice. during editing, she noticed that she missed recording the beginning of a shot in the
Ray Of Light [21]

Bertha should use end roll technique so that she doesn't miss the initial action of a drama.

b. end roll

<u>Explanation:</u>

End roll is a simple method to decide whether the film is pushing ahead or not. When you utilize the film advance to wind the film, you essentially need to check if the handle on the left (that you use to rewind the film) is turning.

In the event that it turns, great, it implies that the film is appropriately locked in. So Bertha should utilize the end move strategy with the goal that she doesn't miss the underlying activity of a dramatization.

5 0
3 years ago
You are researching RAM for a computer you are building for a friend who will be using the system as a home office server for he
pashok25 [27]

Answer:

ECC RAM

Explanation:

ECC RAM is the most popular Random Access Memory out there that is used by most business servers. Dealing with big data for most huge businesses is crucial. The need to prevent loss of data requires that they purchase ECC RAM. ECC RAM automatically protects the systems from potential errors that occur in memory. Any abrupt changes in temporary data stored in ECC RAM are automatically corrected. This is achieved by an additional memory chip that acts as error detection for the other eight RAM chips.

8 0
3 years ago
Other questions:
  • In the game of economics, which player has the role of providing goods and services
    10·1 answer
  • The data I collect in Google Forms are all compiled in a spreadsheet for me.<br> False <br> True
    12·2 answers
  • What is the name for a partition that has been formatted and assigned a drive letter?
    8·1 answer
  • A benefit of flashcards is that they are
    7·2 answers
  • When you open as many links as you want, and still stay in the same browser window instead of cluttering your screen with multip
    5·1 answer
  • Free points,
    15·2 answers
  • What happens when a string doesn’t include the separator that’s specified in the parameter of the split() method?
    13·1 answer
  • How do you change the order of the slides in your presentation in the slide pane 
    15·2 answers
  • Read the following scenario. How might Sarah correct successfully complete her task?
    6·1 answer
  • What is the benefit of hosting a website on a personali
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!