If appropriate, I would like to have askForInterger function store the value from the cin as an interger and use it in the main function or another function. how can i do this? or what would be a better way to do this?
As it stands, the function askForInterger() doesn't return anything. If you want to be able to use the variable outside of that function, it needs return type int
int askForInterger(void)
Secondly, the variable iVal has only local scope, so it doesn't exist outside of the function. You can fix this by moving the delcaration to a global position (outside of a function body; I put my global variables right under the using directive)
Just remember that if main calls another function to do anything with iVal, that function needs to have the variable as an argument