# MIXED VARIABLES IN A FUNCTION CALL

Posted by myospreyuser
Announcements Last Post
SoC Curricula 09/30/2017 01:08PM
Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
School of Computing Short Learning Programmes 11/24/2014 08:37AM
Unisa contact information 07/28/2011 01:28PM
 MIXED VARIABLES IN A FUNCTION CALL March 28, 2010 05:21PM Registered: 9 years ago Posts: 4 Rating: 0
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?

 Re: MIXED VARIABLES IN A FUNCTION CALL March 29, 2010 10:22AM Registered: 13 years ago Posts: 129 Rating: 0
void functions return nothing.... you cannot use the return keyword in a void function
 Re: MIXED VARIABLES IN A FUNCTION CALL March 30, 2010 07:37AM Registered: 13 years ago Posts: 1,424 Rating: 0
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 Registered: 9 years ago Posts: 2 Rating: 0
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.