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
Is Using programming libraries is one way of incorporating existing code into new programs true
postnew [5]

Yes, Using programming libraries is one way of incorporating existing code into new programs  is a true statement.

<h3>What function do libraries provide in programming?</h3>

Programming libraries are helpful resources that can speed up the work of a web developer. They offer prewritten, reuseable portions of code so that programmers can easily and quickly create apps. Consider building a program that enables users to enroll in and pay for courses.

Therefore, Using a code library often saves developers from having to create everything from scratch. It can take less time to develop projects and have more reliable software if the catalog of programming resources is kept up well.

Learn more about libraries from

brainly.com/question/17960151
#SPJ1

6 0
2 years ago
Main components of Adobe photoshop are. ...............
Sergio039 [100]

Answer:

The correct option is;

d) All of this

Explanation:

The main components of Adobe Photoshop are;

1) Title bar displays the name of the application, as well as the name of the current document and it is located at the top of the document window

2) Tool bar is the component of the interface design in which on-screen buttons, menus, icons, and other features for input and output are placed

The tools palette is the toolbar in Adobe Photoshop

3) Menu bar consists access to the basic components such as file, edit, image, layer, used to create new jobs, compose, and edit images.

5 0
3 years ago
A report that ends with the author providing his or her plan for next steps is considered a
Angelina_Jolie [31]
The specific part of the report wherein the author would provide his suggestions on the next plans that would be carried out in the study would be the recommendations. In addition, it would open the opportunity to other aspiring researchers to expound and better improve the study.
4 0
3 years ago
you have an ipv4 network that has two IPv6-only hosts that need to be able to communicate with each other. You want to implement
Soloha48 [4]

Answer:

Teredo tunnelling

Explanation:

The tunnelling method that will fit best in the situation is teredo tunnelling. The reason are embedded in its characteristics, they include;

Teredo tunneling has the following characteristics: Its tunnel endpoints are configured on hosts. The hosts are dual stack hosts and perform tunneling of ipv6 to send on the ipv4 network works through NAT the only solution that allows ipv4-only hosts to communicate with ipv6-only hosts is NAT-PT.

7 0
3 years ago
How many discussion posts must you complete to meet the Expectations of the replies category
Dennis_Churaev [7]

Answer:

I want to take this time to discuss a few expectations and helpful information about how to participate in the weekly online discussions. You can scroll down the page or use the links here to navigate to each section.  All Discussions can be found by clicking on the Discussions link located on the left-hand side of the course.

Explanation:

Participation in the discussion forums is critical for maximizing student learning in this course, both because your participation is graded and because it's a chance to engage in a dialogue about course material.  In this course, students are required to be a part of an online community of learners who collectively interact, through discussion, to enhance and support the professional performance of each other. Part of the assessment criteria for the course includes evaluating the quality and quantity of your participation in the discussion forum.

The TAS will facilitate student discussions, although they likely will not address every single post. In most cases, they might share a related idea, intervene when the discussion goes off-track, or tie student comments together to help deepen student learning.  Remember, if you have a specific question, pose

3 0
3 years ago
Other questions:
  • Your client expresses that they want their new website to have a responsivedesign with consistent coding. They are concerned wit
    5·1 answer
  • A navigation device that transfers packets of data between two or more networks is called a _______
    12·1 answer
  • What wireless networking radio frequency yields faster speeds but offers shorter range ?
    11·1 answer
  • Corey set up his presentation for delivery to his team. The information he had to convey was critical to their job performance.
    6·3 answers
  • What is the top folder of the file tree called
    5·2 answers
  • What social media profession entails determining how and in what way an organization will create and maintain a social media pre
    7·1 answer
  • Bradley is working on a program that uses different classes in specific relationships. Help him remember what these relationship
    14·1 answer
  • What defines the scope of a project?
    5·1 answer
  • Alina is using a small database that uses just one table to store data. What type of database is Alina using?
    8·1 answer
  • What should you implement to leverage power, cooling, and networking capabilities independent from other datacenters in a region
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!