zeroliken
Veteran Poster
1,106 posts since Nov 2011
Reputation Points: 201
Solved Threads: 162
will only run if I enter the biggest number first, & it's suppose to be smallest first.
which variable are you talking about?
plus could you explain your operation
zeroliken
Veteran Poster
1,106 posts since Nov 2011
Reputation Points: 201
Solved Threads: 162
int nn = begin;
put this outside the loop and use nn in the loop condition instead
zeroliken
Veteran Poster
1,106 posts since Nov 2011
Reputation Points: 201
Solved Threads: 162
you forgot the
and use nn in the loop condition instead
while(nn < end)
zeroliken
Veteran Poster
1,106 posts since Nov 2011
Reputation Points: 201
Solved Threads: 162
Thank you!
I am having trouble with:
int nn = begin;
while(nn < end)
{
nn++;
sum += nn;
avg = sum/nn;
}
is there something I am missing or have incorrect?
could you explain the "trouble" with it
...if it's the average put avg = sum/nn; after the loop
zeroliken
Veteran Poster
1,106 posts since Nov 2011
Reputation Points: 201
Solved Threads: 162
hmm..I tried running the program and I was able to successfully get the sum and average? did you compile and saved the changed code?
zeroliken
Veteran Poster
1,106 posts since Nov 2011
Reputation Points: 201
Solved Threads: 162
Then it must be my computer? :[
Did you solve it?
in case not yet, try using using cout statements for all the variables at all parts of the code to know where the problem is by knowing which of these variables is giving garbage value.
try it before and after the initializations and at the end of the functions
zeroliken
Veteran Poster
1,106 posts since Nov 2011
Reputation Points: 201
Solved Threads: 162