How to print the sum of all even and odd numbers from 1 to n in C++