Need Help cant cout the for loop

Mar 1, 2012 at 6:27pm
;;;;;
Last edited on Apr 30, 2012 at 8:18pm
Mar 1, 2012 at 6:39pm
instead of
1
2
for(n=1;n<=num;n++)
sum+=n;


1
2
3
4
5
for(n=1;n<=num;n++) {
cout<<n<<" + ";
sum+=n; }

cout<<" = "<<sum;
Mar 1, 2012 at 6:55pm
@timmyyyyy

This does work but for the output when I put in a number
it shows
1+2+3+4+5+=15

is there a way to not show that + sign after 5

Thanks for you help


Mar 1, 2012 at 6:57pm
try this :

1
2
3
4
5
6
for(n=1;n<num;n++) {
cout<<n<<" + ";
sum+=n; }

sum+=n;
cout<<n<<" = "<<sum;
Mar 1, 2012 at 7:01pm
Topic archived. No new replies allowed.