For the first program, consider creating an if statement inside the for loop that reads:
1 2
if (value == 9999)
cout << "You have exited the program." // Or you can code: exit(0);
What "exit(0);" does is exits the program and returns the number stored inside the parentheses as your return case.
Also, you can insert your initial cin >> value; code into the first line of your for loop and rid yourself of the 2nd call if you wish to. Less lines = easier to read = good practice.
Always go back once you finish a program and see if you can do it in less lines of code. I find this helps me create programs faster in the future.