# i am trying to write a code for my school home work but it shows an error

#include <stdio.h>
#include <math.h>
int main()
{
double x, y, z, m, r;
double costMilk, costpaint;
printf("enter height of drum(in cms):");
scanf("%lf", x);

scanf("%lf", y);

scanf("%lf", z);

printf("enter cost of milk(per litre):");
scanf("%lf", m);

printf("enter cost of paint required for 1 sqcm:");
scanf("%lf", r);

costMilk = (((1/3)*(22/7)*x*(y*y + y*z + z*z))*(1/1000))*(m);
printf("the total cost of milk that fills the drum is:%f" , costMilk);

costpaint = ((22/7)*(y + z)*sqrt((z-y)*(z-y) + x*x))*r;
printf("the total cost of painting the drum is:%f" , costpaint);

return 0;

}

answered Oct 8, 2021 by (140 points)

in scanf use & before variable

i.e.

scanf("%lf", &x);

scanf("%lf", x);

Enjoy :)

answered Oct 8, 2021 by (53,530 points)

# The programming part

In scanf(), the additional arguments should be pointers. The & (address of) operator will return the address that points to your variable. See the example shown by abc.

# The mathematics part

## PI vs 22/7

First of all, I was scratching my head why you have 22/7 in your code. I searched the web a bit and found out why. Still, it doesn't make much sense to me. If you want PI, then write PI, not an expression that only approximates it and may be confusing for many. You can create our constant or macro and use that instead.

`#define PI 3.14159265359`

## Volume

First of all, you're talking about a cylinder, but you ask for lower and upper radius. For a cylinder, it's the same. When it is different, it is a truncated cone or conical frustum, which is the tip of a cone cut off.

The volume of the truncated cone is the volume of the larger cone reduced by the volume of the smaller cone.

Vtotal = Vlarge - Vsmall = PI/3 * hlarge * rlarge2 - PI/3 * hsmall * rsmall2

## Area

The area should be calculated similarly, the difference of lateral surface areas plus the two bases.

I have to leave now and I don't have time to finish the maths.

You can find the proper formula on the linked site above.

Note: I believe you have been using the very (or similar) site, but you were using the formula of the square frustum, not the conical frustum.