Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C programing please ;D Write a program that prompts the user to enter a series o

ID: 3764427 • Letter: C

Question

C programing please ;D

Write a program that prompts the user to enter a series of diameters and a height to calculate the volume of a parabolic cone. The equation for a parabolic cone is given by:

V=(2d^2 h)/15
where d is the diameter of the base, h is the height, and V is the volume of the parabolic cone.

Specifications:

Create a project called HW31 in NetBeans and create a hw31.c source file. Make sure that the first line of hw31.c is: /* homework 31 */. Then prompt the user to enter the number of diameters that will be entered from the keyboard. Use the results to create two variable-length arrays: one for the diameter and a second for the volume. Then use a for() loop to scan in a diameter into the appropriate element of the diameter array. After prompting the user to enter a height,calculate the volume using another for()loop, store the result in the appropriate element of the volume array, and print the results in a table. Use the following variable names:

Variable and Array Names
int n – represents the number of diameters to be read in

float diameter[n] – stores the scanned diameters

float height – stores the scanned height


float volume[n] – stores the calculated volumes

Use %6.2f for the output specifier when printing out the diameters, height, and volumes. If you execute the program with the following underlined inputs, the results will be:

~> hw31.o
Enter the number of diameters: 3

Enter a cone diameter: 1

Enter a cone diameter: 2

Enter a cone diameter: 3

Enter a cone height: 4

Explanation / Answer

/* homework 31 */
#include <stdio.h>
#include <stdlib.h>


int main(int argc, char *argv[])
{
  
int n,i;
float pi=3.14;

printf("Enter the number of diameters:" );
scanf("%d",&n);
float diameter[n];
float height;
float volume[n];

for(i=0;i<n;i++)
{
printf("Enter a cone diameter:");
scanf("%f",&diameter[i]);        
               
}
    printf("Enter a cone height:");
scanf("%f",&height);    
for(i=0;i<n;i++)
{
volume[i]=(2*pi*diameter[i]*diameter[i]*height)/15;
               
}   
printf("Diameter Height Volume ");
for(i=0;i<n;i++)
{
printf("%6.2f",diameter[i]);
printf(" %6.2f",height);
printf(" %6.2f",volume[i]);
printf(" ");
               
}

  
  
  

system("PAUSE");  
return 0;
}