PROGRAM 6: Volume Finder For a pyramid, a cone or a cylinder, their volumes can
ID: 3918236 • Letter: P
Question
PROGRAM 6: Volume Finder
For a pyramid, a cone or a cylinder, their volumes can be computed from the parameters b, r and h, as shown below:
Volume = pi * r * r * h
Write an HLA Assembly language program that computes and then prints the volume of a pyramid, cone and cylinder based on a radius r, a length b and a height h by writing a function with the following signature:
A sample program dialogue is shown below.
Lemme calculate the volumes of various things!
Gimme r: 1.0
Gimme b: 1.0
Gimme h: 1.0
Volume of a pyramid = 0.33333
Volume of a cone = 1.04719
Volume of a cylinder = 3.14159
Lemme calculate the volumes of various things!
Gimme r: 1.0
Gimme b: 1.0
Gimme h: 3.0
Volume of a pyramid = 1.00000
Volume of a cone = 3.14159
Volume of a cylinder = 9.42477
Lemme calculate the volumes of various things!
Gimme r: 2.0
Gimme b: 1.0
Gimme h: 3.0
Volume of a pyramid = 1.00000
Volume of a cone = 12.5663
Volume of a cylinder = 37.6991
Volume = pi * r * r * h
Explanation / Answer
#include <stdio.h>
#include <math.h>
int main()
{
float radius, height;
float surface_area, volume;
printf("Enter value of radius and height of a cone : ");
printf("Enter value of lenghth and height of a pyramid : ");
printf("Enter value of radius and height of a cylinder : ");
scanf("%f%f", &radius, &height);
scanf("%f%f", &length, &height);
scanf("%f%f", &radius, &height);
volume = (1.0/3) * (22 / 7) * radius * radius * height;
volume = (1.0/3) * (22 / 7) * lenghth * height;
volume = (22 / 7) * radius * radius * height;
printf(" Volume of cone is : %.3f", volume);
printf(" Volume of pyramid is : %.3f", volume);
printf(" Volume of cylinder is : %.3f", volume);
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.