Functions and Parameters
In the following code I do not understand why we need to create a function to output a number. Is this better than just creating a variable named X and assigning a value? This code came from your tutorial "Function Parameters" Question 2/3. I got real lost in my C++ Programming book at this chapter. Came here for more learning and help as recommended by a friend. Here is the code: Function Parameters Once parameters have been defined, you can pass the corresponding arguments when the function is called. For example: #include <iostream> using namespace std; void printSomething(int x) { cout << x; } int main() { printSomething(42); } // Outputs 42 Try It Yourself The value 42 is passed to the function as an argument, and is assigned to the formal parameter of the function: x. Making changes to the parameter within the function does not alter the argument.