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;
}
Step-by-step explanation:
The function begins here
#include <stdio.h>
This defines the function
int C_ball(int height){
If height is 1, return 1
if(height == 1) {
return 1;}
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
printf("Height: ");
scanf("%d",&n);
This calls the function
printf("Balls: %d",C_ball(n));
return 0;
}