Question

The volume of a cylinder can be computed as: v = π * r * r...

The volume of a cylinder can be computed as: v = π * r * r * h Write a C++ function that computes the volume of a cylinder given r and h. Assume that the calling function passes the values of r and h by value and v by reference, i.e. v is declared in calling function and is passed by reference. The function just updates the volume v declared in calling function. The function prototype is given by: void vol_cyl(float r, float h, float& v); Write a main program that prompts the user to enter the values of r and h. It then calls the function vol_cyl to compute the value of volume and update its value in the main program. It then prints out the values of radius, height and volume on the screen.

Homework Answers

Answer #1

#include <iostream>

using namespace std;

void vol_cyl(float r,float h,float &v)
{
v=3.14*r*r*h;
}

int main()
{
float v;
vol_cyl(2.3,4.5,v);
cout<<"volume is :"<<v;

return 0;
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Suppose the radius, height and volume of a right circular cylinder are denoted as r, h,...
Suppose the radius, height and volume of a right circular cylinder are denoted as r, h, and V . The radius and height of this cylinder are increasing as a function of time. If dr/dt = 2 and dV/dt = 10π when r = 1, h = 2, what is the value of dh/dt at this time?
The volume of a right circular cylinder is given by V= πr2h, where r is the...
The volume of a right circular cylinder is given by V= πr2h, where r is the radius of its circular base and h is its height. Differentiate the volume formula with respect to t to determine an equation relating the rates of change dV/dt , dr/dt , dh/dt.   At a certain instant, the height is 6 inches and increasing at 1 in/sec and the radius is 10 inches and decreasing at 1 in/sec. How fast is the volume changing at...
Let V be the volume of a cylinder having height h and radius r, and assume...
Let V be the volume of a cylinder having height h and radius r, and assume that h and r vary with time. (a) How are dV /dt, dh/dt, and dr/dt related? (b) At a certain instant, the height is 18 cm and increasing at 3 cm/s, while the radius is 30 cm and decreasing at 3 cm/s. How fast is the volume changing at that instant? Is the volume increasing or decreasing at that instant?
Write a Python program named lastNameVolumes that finds the volumes of different 3 D objects such...
Write a Python program named lastNameVolumes that finds the volumes of different 3 D objects such as a cube, sphere, cylinder and cone. In this file there should be four methods defined. Write a method named cubeVolFirstName, which accepts the side of a cube in inches as an argument into the function. The method should calculate the volume of a cube in cubic inches and return the volume. The formula for calculating the volume of a cube is given below....
in java Implement a class Balloon. A balloon starts out with radius 0. Supply a method...
in java Implement a class Balloon. A balloon starts out with radius 0. Supply a method public void inflate(double amount) that increases the radius by the given amount. Supply a method public double getVolume() that returns the current volume of the balloon; volume of a balloon is represented as: V = (4/3) * PI * r^3 Use Math.PI for the value of π. To compute the cube of a value r, you can use Math.pow (https://www.tutorialspoint.com/java/lang/math_pow.htm) or r*r*r Write a...
Write a C++ program which consists of several functions besides the main() function. 1)   The main()...
Write a C++ program which consists of several functions besides the main() function. 1)   The main() function, which shall ask for input from the user (ProcessCommand() does this) to compute the following: SumProductDifference and Power. There should be a well designed user interface. 2)   A void function called SumProductDifference(int, int, int&, int&, int&), that computes the sum, product, and difference of it two input arguments, and passes the sum, product, and difference by-reference. 3)   A value-returning function called Power(int a,...
Write a program which inputs an integer value, incr, from the user at the keyboard, and...
Write a program which inputs an integer value, incr, from the user at the keyboard, and then displays a graph of the sine of the degree values from 0 to 180, in increments of incr. You must use the sin function (in a similar manner to ceil and floor) to find the sine. Note that the sin function only operates on radians so the degree value must first be converted to radians. To do so, multiply the degree value by...
I NEED TASK 3 ONLY TASK 1 country.py class Country:     def __init__(self, name, pop, area, continent):...
I NEED TASK 3 ONLY TASK 1 country.py class Country:     def __init__(self, name, pop, area, continent):         self.name = name         self.pop = pop         self.area = area         self.continent = continent     def getName(self):         return self.name     def getPopulation(self):         return self.pop     def getArea(self):         return self.area     def getContinent(self):         return self.continent     def setPopulation(self, pop):         self.pop = pop     def setArea(self, area):         self.area = area     def setContinent(self, continent):         self.continent = continent     def __repr__(self):         return (f'{self.name} (pop:{self.pop}, size: {self.area}) in {self.continent} ') TASK 2 Python Program: File: catalogue.py from Country...
Complete this in C++ and explain what is being done. 1      Introduction The functions in the...
Complete this in C++ and explain what is being done. 1      Introduction The functions in the following subsections can all go in one big file called pointerpractice.cpp. 1.1     Basics Write a function, int square 1(int∗ p), that takes a pointer to an int and returns the square of the int that it points to. Write a function, void square 2(int∗ p), that takes a pointer to an int and replaces that int (the one pointed to by p) with its...
Using C++, Python, or Java, write a program that: In this programming exercise you will perform...
Using C++, Python, or Java, write a program that: In this programming exercise you will perform an empirical analysis of the QuickSort algorithm to study the actual average case behavior and compare it to the mathematically predicted behavior. That is, you will write a program that counts the number of comparisons performed by QuickSort on an array of a given size. You will run the program on a large number of arrays of a certain size and determine the average...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT