I don't understand this assignment and what I should do.
Write a function called twenty that takes an integer variable as input and changes that variable to be the number that would need to be added to it to make its sum twenty.
i.e. int number = 15;
twenty(number);
First, you have to think: The number that is added to the user input to get twenty, is also equal to the user input subtracted from twenty.
Therefore, have the user input an integer value, and store it in a variable of type "int". This is an integer type variable.
Next, have a variable called something along the lines of "Output_Value".
Set this "Output_Value" equal to 20, the total, minus the user input. Therefore, this "Output_Value" will be equal to the number that is added to the user input to equal 20.
Then simply do cout << "Ouput_Value".
(To do this as a function....)
Get the user input before the function call.
Next, use the user input as a parameter in the function. Then determine "Output_Value" and print it to the console. If you want, you can define the function as an integer function, and return "Output_Value" to the main function, and print it from here.
@ Programmer3: I read this as the teacher wanting him to write a function with a pointer as an argument. Otherwise they would ask for a function that returns the difference not "changes the number" to be the difference. YMMV but that's how I read it.