Ans)C++ code:
#include <cmath>
#include <iostream>
using namespace std;
double volumeOfCone(double, double);
int main( )
{
//Declare variables and constants
double radiusOfCone = 0.0;
double heightOfCone = 0.0;
//Prompt the user for inputs
cout << "Enter the radius of the cone: ";
cin >> radiusOfCone;
cout << "Enter the height of the cone: ";
cin >> heightOfCone;
cout << "The volume of your cone is: " <<
volumeOfCone(radiusOfCone, heightOfCone) << endl;//Call the
function and Display the result
system("pause");
return 0;
} //end of main
double volumeOfCone(double radiusOfCone, double heightOfCone)
//function that calculates and returns the volume of a cone
{
double PI = acos(-1.0); //initializing value of PI
double volume = radiusOfCone * radiusOfCone * heightOfCone * PI /
3.0;//valculating the volume of a cone
return volume;// returning the volume
}
output:
Write the prototype of a function called volumeOfCone that calculates and returns the volume of a...
C++ ( Please Read) Write a function prototype and a function definition called getTotal that receives an array of type double, the number of rows in the array. It returns the total of all elements in the array.
(5.00 Points) 11 - The function prototype double mySqrt(int x); defines a function called a) double which calculates square roots b) mySqrt which takes an integer as an argument and returns a double c) mysqrt which takes an argument of type x and returns a double d) mysqrt which takes a double as an argument and returns an integer
4. Write a C definition (prototype) for a function called power which takes a float and an integer as inputs, and returns a float as a result. 5. Write the body of the function from (4). This function should raise the first argument to the power of the second, by multiplying it by itself that many times (don’t use the inbuilt pow function, write your own). Do not worry about “special” cases like negative powers. Please do Q.5
Write a function prototype and a function definition for a function called Numbers that takes three arguments by reference, all of type long, and displays the sum, average, and largest of its three arguments.
C++ //Write prototype for function factorial that accepts an int num and returns an int /* WITH LOOP OF YOUR CHOICE: Write code for function factorial that accepts an int num and returns the num's factorial factorial(5); 1*2*3*4*5 returns 120 DON'T FORGET TO WRITE TEST CASE. */ //write includes statements //write using statements for cin and cout /* Use a do while loop to prompt the user for a number, call the factorial function, and display the number's factorial. Also,...
Python 1 Write a function called sum_odd that takes two parameters, then calculates and returns the sum of the odd numbers between the two given integers. The sum should include the two given integers, if they are odd. You can assume the arguments will always be positive integers, and the first smaller than or equal to the second. 3 To get full credit on this problem, you must define at least 1 function, use at least 1 loop, and use...
Write a C function named isSymmetric, the prototype of which is given below, that returns 1 if the elements of an array of integers named myArray of size n are symmetric around the middle. If the array elements are not symmetric, the function should return 0. Both the array and its size are specified as parameters.
Write a C++ program using a function called sum that calculates the following summation: p=2+5 F = i2 + 5 i=1 Where n is provided by the user in the main function. The function calculates the sum and return it to the main function to display it.
write C code that uses pointers, arrays, and C strings. 3. Write a function called pow_xy. The function should be passed 2 parameters, as illustrated in the prototype below. int pow_xy(int *xptr, int y); Assuming that xptr contains the address of variable x, pow_xy should compute x to the y power, and store the result as the new value of x. The function should also return the result. Do not use the built-in C function pow. For the remaining problems,...
For my question, I need to write a function in Python 3 called middle that takes a list and returns a new list that contains all elements but the first and last elements. After the implement this function, I need to pass lists to test the functionality of the middle function Prototype: middle(list)