hi! good day im a newbie and trying to learn functions in C. and im having a problem with functions.

int charges (int l, int w)
{
int c_charg;
c_charg = 8.23 * area;
}

l = 6, w= 3, and area = 18

problem is 'c_charg' is assigned a value which is never used in function charges. and i don't understand what seems to be the problem. please help!

You're not returning anything in your function, which is supposed to return an int, so any information in c_charg is lost.

Also, where does area come from? You need to declare this in the function and calculate it with the length and width that are being passed into the function.

Finally, look at the calculation for c_charg - you're multiplying 8.23 times a quantity and trying to store it in an int. The value will be truncated into an int, and anything after the decimal point will be lost.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.