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?
C++ questions 5.Which of the following function prototype(s) are correct. void setValue(int &value); void setValue(int &);...
C++ questions 5.Which of the following function prototype(s) are correct. void setValue(int &value); void setValue(int &); void setValue(int value, int max=100); void setValue(int ++value); 6. T/F Calling an overloaded function can result in multiple values being returned to the caller. 7.A ____ function has ____ return value(s), but can have ____ parameter(s). Otherwise a function can return _____ value(s). 8.T/F Only variables can be passed as reference. 9.T/F When writing a C++ program you must be careful to arrange all...
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,...
Description: The purpose of this assignment is to practice writing code that calls functions, and contains...
Description: The purpose of this assignment is to practice writing code that calls functions, and contains loops and branches. You will create a C program that prints a menu and takes user choices as input. The user will make choices regarding different "geometric shapes" that will be printed to the screen. General Comments: Your code must contain at least one of all of the following control types: nested for() loops a while() or a do-while() loop a switch() statement an...
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 was asked to write a program in CodeBlocks. C++ format. I've written the first half...
I was asked to write a program in CodeBlocks. C++ format. I've written the first half of the code but I am using else and if statements. I feel like the code is too long to do a simple calculation. In CodeBlock when you build and run your code, a new terminal window opens (in windows a new console window) and you can enter your inputs there. It is not like eclipse that you enter your inputs in console view....
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT