Hello everyone I am lost with functions. The only part I am stuck on is the functions. I can't seem to grasp the concept. Any help would be greatly appreciated!. Here is the goal of this exercise:
Write a program that prompts the user to enter two integer values. Display every whole number that falls between these values. (This is deceptively simple. Don't over think it! :))
Modify the program to use a function. The main () program should just prompt the user for the values and the function should display the results. (Do not use global variables.)
Here's the code I came up with to put into the function:
I don't think you want to return anything from the function. I can't see anything in the task that specifies you need to return a value.
The problem here is that you want to pass two numbers into your function, but you're not doing so.
Your function should look something like this:
1 2 3 4
void PleaseWork(int a, int b)
{
// Code here
}
Within the scope of your function, that is everything between the curly braces, a and b now represent the numbers passed in. So if you want to work out every number between those two, you need to do a for loop, similar to the oneyou have only starting at a + 1 and ending at b - 1.
Hope this helps.
EDIT: C++ is a soulless mistress. Naming your function PleaseWork won't persuade her to work for you. Might be better off giving it a more meaningful name. :-)
EDIT: C++ is a soulless mistress. Naming your function PleaseWork won't persuade her to work for you. Might be better off giving it a more meaningful name. :-)
LOL I sure will
Thanks for the input Hutch I think I can solve this one now! I had to step away for a minute and come back to it.