Welcome! Log In Create A New Profile

Advanced

MIXED VARIABLES IN A FUNCTION CALL

Posted by myospreyuser 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
MIXED VARIABLES IN A FUNCTION CALL
March 28, 2010 05:21PM
How do i call a function with mixed variables?

eg:

float DailyWorkout(float hours, float days)

the above will work, but if I mix variables the compiler will complain.

eg:

float DailyWorkout(float hours, int days)

how would i call a function with mixed variables from the main().
and how do I initialize them. Should I initialise the variable as a float then convert it to an integer after returning from the function?
And will the same apply in a void function?

Please advise and show an example.
Re: MIXED VARIABLES IN A FUNCTION CALL
March 29, 2010 10:22AM
void functions return nothing.... you cannot use the return keyword in a void function
avatar Re: MIXED VARIABLES IN A FUNCTION CALL
March 30, 2010 07:37AM
Yes you can. You just don't return a value.

Language: C++
void calculateDeterminant(int index){ if (index < lowerBoundary || upperBoundary < index) return; // index is out of range, skip the rest of the funtion   // rest of function that does stuff }
Re: MIXED VARIABLES IN A FUNCTION CALL
April 16, 2010 02:32PM
Hi if you mix variables then use Void function but note void function does not return a value instead can store the value in a variable.
So try it like the one below:


void DailyWorkout(float hours, float days)
Sorry, only registered users may post in this forum.

Click here to login