There are many things wrong.
1) On the line of sumArray's declaration you are most probably missing a 0 between the equal and semi-colon signs;
Thanks fixed.
2) You are never defining the variable n thus completely messing sumArray and your whole summation() function;
Isn't it declared in line 5?
3) The error right above is because you most probably think that your int enumeration at the top is setting all those variables to 0 but it is not doing this. It sets only sum to 0;
Is there any way to fix this without declaring each one individually to 0?
4) sumArray has no initial values thus using it in your calculations is just plain wrong;
for a dynamic array can I just use
Code:
sumArray = new int[n];
to set it to 0?
5) Your if() statement does nothing given that it will always be executed after the while loop;
How so...when I compile this the first time it does not ask me to enter C or Q, however every time after time it asks me to enter C or Q and then continues if I enter C and quits if I enter q. Doesn't that mean the if statement is working?
6) You are not using delete[] to free previously allocated memory.
Thanks fixed.
I would also note that a typedef is useless and unwanted in this case and using dynamic memory allocation is questionnable at best in this code. This could easily be done in 3-4 lines of code without that many variables and stuff.