Lets see:
Line 2. The standard library provides <cmath> for C++.
Besides, what do you use from that header? Nothing.
Line 3. Avoid this form. Use minimal amount of exposure:
1 2
|
using std::cout;
using std::cin;
|
Lines 5-7. Global variable. Avoid them. They have their place and use, when you really know that you have to use them. This is not the place.
Line 29. Thou shalt not call main(). Use a loop instead.
1 2 3 4
|
char glados = 'n';
do {
// something
} while ( std::cin >> glados && 'y' == glados );
|
Line 14. The 'z' within the function is the function argument 'z', not the global 'z'.
Line 17. You do promise on line 9 to return an int, but you don't.
Line 23. You do call the addDigits with 'z'.
Line 23. You don't store the int returned by the function addDigits.
Line 9. The addDigits takes argument 'z'
by value. A copy. It will not change the caller's parameter.