Reputation: 267
I would like to ask a certain question in regards to C programming.
I have a function which takes a parameter 'x'.
The function is supposed to do actions based up on the x.
So i have a source file where i have this function
file.c
y=random number
And i want to call this function to do actions.
function(x);
And now x must be equal to y
Well the problem here is i want to pass y value to x.
Is there any regular way of doing so?
If there is any please help me understand and also to make it clearer.
Regards Rookie
Upvotes: 1
Views: 92
Reputation: 8286
Within your function(x), x will be equal to whatever value is pass to the function. If you use function(y), then within the function, x will be equal to y. If you use function(7), then x would be equal to 7. Functions are usually defined with a return type and a parameter type.
void function( int x)
would define function that takes a type of integer and returns nothing.
int function( int x)
would define a function that takes a integer value and returns a integer value.
double function( int x, double z)
would define a function that takes an integer and a floating point and returns a floating point value.
Upvotes: 1