Answer to Question #261786 in C for reem

Question #261786

Write a program that reads the values for the width, length, and height of a rectangular box using three variables of double type in the function main(). Pass values of these variables to a function, which calculates the volume and surface area for six sides of the box. The volume and surface area of the box passed back from two other arguments of this function are printed out in the function main(). Check your program with the user input for the width, length, and height of 2, 3, 4 meters, respectively.


1
Expert's answer
2021-11-05T17:21:08-0400
#include <stdio.h>


void calculataVolumeAndArea(double w, double l, double h){
    double volume=l*w*h;
    double area=2*(l*w)+2*(l*h)+2*(h*w);
    printf("\nVolume of the Box = %lf",volume);
    printf("\nSurface Area = %lf",area);
}
int main()
{
    double width, length, height;
    printf("\nEnter width: ");
    scanf("%lf",&width);
    printf("\nEnter length: ");
    scanf("%lf",&length);
    printf("\nEnter height: ");
    scanf("%lf",&height);
    calculataVolumeAndArea(width,length,height);


    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS