Sunday, January 31, 2010

Error Returned Creating The Volume User Defined Functions In C?

User Defined Functions in C? - error returned creating the volume

I have a project in my class C programming, but I did create a bit of the character of trouble.ie does a user role in order to calculate the volume of the sphere given the radius.

The function must be called sphere_volume) called from the main program.

When calling from the main program look like, which reads as is: sphere_volume (R);

This is what I am now, but I keep getting an error. Suggestions? THANKS


/ / Class Redo.cpp: Defines the entry point for the console application.

# "Include Stdafx.h
# "Include math.h

sphere_volume double (double r, int v);


int / * _t * / int main (void) / / (int argc, char * argv [])
(
RW
v;

/ * Request * RADIO /

printf ( "Enter the radius of the circle:")
scanf ( "% d", & R);

/ * Output volume * /

printf ( "Volume is% f \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ n", sphere_volume (r));


return 0;
)

sphere_volume (Double R)
(
v =4 / 3 * 3.14 * pow (r, 3);
return (v);
)

3 comments:

The Phlebob said...

That is always a good idea to tell us what errors you see. In this case, here I noticed. In this code:

sphere_volume (Double R)
(
v = 4 / 3 * 3.14 * pow (r, 3);
return (v);
)

v is not defined. V You have a local variable in main (), but sphere_volume set () do not know. Since this is a temporary variable sphere_volume () must be defined here.

At second glance, his statement sphere_volume ()

sphere_volume double (double r, int v);

differs from the definition:

sphere_volume (Double R)

This is probably due to an error by the compiler or linker. Even here, however, as you turn the volume and value of the function are not necessary given V as a parameter.

I hope that helps.

Zander said...

They do not tell us what mistakes you will always be

It appears that you assign a value v av undeclared

try

Double = 4 / 3 * 3.14 V * pow (r, 3);

MichaelI... said...

... or even better:
Previous 4 / 3 * 3.14 * pow (r, 3);

then you need not declare a variable

Post a Comment