void example(Can you put anything in here?)

void game(Can i put anything here?) {
}

is a function definition.

void means that the function does not return a value. Remember in math class when you had functions like sin(x) and they returned a value (like sin(pi) = 0, the 0 is what the function sin computed and returned to you).

In your case, the void part means no value gets returned (the functions execute and then just finish. The (Can i put anything here?) part of the function call is where the arguments (or parameters) go. You cannot put anything there, you have to put the arguments to the function there, such as int i:

void game(int i) {
}

now you can call the function and pass it an integer game(5) and inside the function you can gain access to the value 5 via the variable i. The function can perform the tasks you tell it to (in the case of sin it would take i and compute and return the sine value).

Leave a Comment