Need Help cant cout the for loop

;;;;;
Last edited on
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;
@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


try this :

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

sum+=n;
cout<<n<<" = "<<sum;
Topic archived. No new replies allowed.