answersLogoWhite

0

You can do this by creating a forwarddeclaration of the function. You can call the forward drclared function inside the main to use it.


int result(float num1, float num2);


int

main(void)

{

int value = result(3.14, 2.74);

return (0);

}


int

result(float num1, float num2)

{

int value = 0;

// function codes goes here

// you can alter the value of variable 'value'

return (value);

}


The returning value of the 'result()' function is assigned to variable 'value' in 'main()'.

User Avatar

Wiki User

8y ago

What else can I help you with?

Continue Learning about Engineering

What module returns a value back to the part of the program that called it?

A function. You can have a function that returns but doesn't return a value with it.


What function must be in all c plus plus programs?

Every C++ program must have a main() function that returns an integer:int main(){// user-code goes here....// Main must return an integer to the calling program.// A non-zero value usually indicates an error occurred but// the exact meaning of the return value is user-defined.return( 0 );}


What is a variable that is used within a function?

If the variable is declared within the function body, it is a local variable, one that is local to the function. Local variables fall from scope when the function returns, they are only accessible within the function. However, local variables can be returned by value, which creates an automatic variable that is returned to the caller. If the caller does not store the return value, the automatic variable falls from scope when the expression containing the function call ends. However, the expression may evaluate the return value without storing it. Note that functions cannot return local variables by reference since the local variable falls from scope when the function returns. If the variable is passed as an argument to the function, then the variable is a parameter of the function. Arguments may be passed by value or by reference, depending upon the function signature. Passing by value means the function parameter is a copy of the argument (if the argument is an object, the object's copy constructor is invoked automatically). Thus any changes made to the parameter within the function are not reflected in the argument that was originally passed, and the parameter will fall from scope when the function returns. However, the value of the parameter can be returned as previously explained. Passing by reference means the function parameter refers directly to the argument that was passed. Thus any changes made to the parameter are reflected in the argument. Parameters that are declared as constant references assure the caller that the reference's immutable members will not be altered by the function. If the parameter is a non-const reference but the caller does not wish changes to be reflected in the argument, the caller should pass a copy of the argument instead.


Describe a chicken using a programming language?

chicken is a function which takes argument as grain type and returns egg. egg chicken(grain x);


Difference between sizeof and strlen?

The sizeof operator returns the total size, in bytes, of the given operand, whereas the strlen function returns the number of characters in the argument up to but not including the first null-terminator.Consider a character buffer allocated 50 bytes to which you assign the string "Hello world". The sizeof operator will return 50, but the strlen function returns 11.

Related Questions

A function prime that returns if its argument is a prime no or returns zero?

prime number


Can you write a program without specifying the prototype of any function?

You can write a program without specifying its prototype when the function returns an integer.If the prototype is not mentioned the compiler thinks that the return type of the function used is integer.When making program which return integer you can ignore writing the protoype.


What module returns a value back to the part of the program that called it?

A function. You can have a function that returns but doesn't return a value with it.


What is a named operation that returns a value in the Excel program used to simplify formulas?

A function.


What are the conditional logic functions in computer applications?

Not sure what you are asking here, but here is my best guess.COMPUTER PROGRAMMING APPLICATIONS:IF - If a condition exists, do something, if not, do something else.CASE - If a condition equals CASE1 do this; if CASE2 do this; etc.WHILE - If a condition remains, keep doing something until the condition changes.EXCEL:AND(logical1,logical2,...) - tests whether the logical arguments are TRUE or FALSE. If they are all TRUE, the AND function returns TRUE to the cell. If any are FALSE, the AND function returns FALSE.IF(logical_test,value_if_true,value_if_false) - tests whether the logical_test expression is TRUE or FALSE. If TRUE, the IF function returns the value_if_true argument. If FALSE, the IF function returns the value_if_false argument.IFERROR(value,value_if_error) - tests whether the value expression is an error. IFERROR returns value_if_error if the expression is an error, or value of the expression if it is not an error.NOT(logical) - tests whether the logical argument is TRUE or FALSE. If TRUE, the NOT function returns FALSE. If FALSE, the NOT function returns TRUE.OR(logical1,logical2,...) - tests whether the logical arguments are TRUE or FALSE. If any are TRUE, the OR function returns TRUE. If all are FALSE, the OR function returns FALSE.FALSE() - takes no argument and simply enters logical FALSE in its cell.TRUE() - takes no argument and simply enters logical TRUE in its cell.


Write a function prime that return 1 if its argument is a prime and returns 0 otherwise?

#include<stdio.h> #include<conio.h>main() { }


What function must be in all c plus plus programs?

Every C++ program must have a main() function that returns an integer:int main(){// user-code goes here....// Main must return an integer to the calling program.// A non-zero value usually indicates an error occurred but// the exact meaning of the return value is user-defined.return( 0 );}


Write a function prototype named test that accepts two parameters an integer and character and returns a float?

float test(int, char);


The greatest integer function shown below is defined so that it produces the greatest integer or equal to x.?

The greatest integer function, often denoted as (\lfloor x \rfloor), returns the largest integer that is less than or equal to the given value (x). For example, (\lfloor 3.7 \rfloor) equals 3, while (\lfloor -2.3 \rfloor) equals -3. This function effectively "rounds down" any non-integer value to the nearest whole number.


What is a variable that is used within a function?

If the variable is declared within the function body, it is a local variable, one that is local to the function. Local variables fall from scope when the function returns, they are only accessible within the function. However, local variables can be returned by value, which creates an automatic variable that is returned to the caller. If the caller does not store the return value, the automatic variable falls from scope when the expression containing the function call ends. However, the expression may evaluate the return value without storing it. Note that functions cannot return local variables by reference since the local variable falls from scope when the function returns. If the variable is passed as an argument to the function, then the variable is a parameter of the function. Arguments may be passed by value or by reference, depending upon the function signature. Passing by value means the function parameter is a copy of the argument (if the argument is an object, the object's copy constructor is invoked automatically). Thus any changes made to the parameter within the function are not reflected in the argument that was originally passed, and the parameter will fall from scope when the function returns. However, the value of the parameter can be returned as previously explained. Passing by reference means the function parameter refers directly to the argument that was passed. Thus any changes made to the parameter are reflected in the argument. Parameters that are declared as constant references assure the caller that the reference's immutable members will not be altered by the function. If the parameter is a non-const reference but the caller does not wish changes to be reflected in the argument, the caller should pass a copy of the argument instead.


Describe a chicken using a programming language?

chicken is a function which takes argument as grain type and returns egg. egg chicken(grain x);


What is the formula for base and power in java program?

powpublic static double pow(double a, double b) Returns the value of the first argument raised to the power of the second argument. Special cases: If the second argument is positive or negative zero, then the result is 1.0.If the second argument is 1.0, then the result is the same as the first argument.If the second argument is NaN, then the result is NaN.If the first argument is NaN and the second argument is nonzero, then the result is NaN.If the absolute value of the first argument is greater than 1 and the second argument is positive infinity, orthe absolute value of the first argument is less than 1 and the second argument is negative infinity,then the result is positive infinity.If the absolute value of the first argument is greater than 1 and the second argument is negative infinity, orthe absolute value of the first argument is less than 1 and the second argument is positive infinity,then the result is positive zero.If the absolute value of the first argument equals 1 and the second argument is infinite, then the result is NaN.If the first argument is positive zero and the second argument is greater than zero, orthe first argument is positive infinity and the second argument is less than zero,then the result is positive zero.If the first argument is positive zero and the second argument is less than zero, orthe first argument is positive infinity and the second argument is greater than zero,then the result is positive infinity.If the first argument is negative zero and the second argument is greater than zero but not a finite odd integer, orthe first argument is negative infinity and the second argument is less than zero but not a finite odd integer,then the result is positive zero.If the first argument is negative zero and the second argument is a positive finite odd integer, orthe first argument is negative infinity and the second argument is a negative finite odd integer,then the result is negative zero.If the first argument is negative zero and the second argument is less than zero but not a finite odd integer, orthe first argument is negative infinity and the second argument is greater than zero but not a finite odd integer,then the result is positive infinity.If the first argument is negative zero and the second argument is a negative finite odd integer, orthe first argument is negative infinity and the second argument is a positive finite odd integer,then the result is negative infinity.If the first argument is finite and less than zero if the second argument is a finite even integer, the result is equal to the result of raising the absolute value of the first argument to the power of the second argumentif the second argument is a finite odd integer, the result is equal to the negative of the result of raising the absolute value of the first argument to the power of the second argumentif the second argument is finite and not an integer, then the result is NaN.If both arguments are integers, then the result is exactly equal to the mathematical result of raising the first argument to the power of the second argument if that result can in fact be represented exactly as a double value.(In the foregoing descriptions, a floating-point value is considered to be an integer if and only if it is finite and a fixed point of the method ceil or, equivalently, a fixed point of the method floor. A value is a fixed point of a one-argument method if and only if the result of applying the method to the value is equal to the value.)A result must be within 1 ulp of the correctly rounded result. Results must be semi-monotonic.Parameters:a - the base.b - the exponent.Returns:the value ab.Taken from the Java api.