Successive Addition

I have problem finding the codes of successive addition

for example I want to make a code that when I give it numbers a and b

a=8 b = 3

c= 8*3 = 8+8+8

I want the code that make the 8+8+8....

I tried this : do { result += a; i++; } while (i<b);
But its adding like counter 8+8=16+8=24 etc...
I don't want this.
Thanks
Why do you want what you want?

Remember, that 8+8+8 is same as (8+8)+8 is same as 16+8 ...
You can always make c a string:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
#include <string>

int main()
{
    int a = 8, b = 3;
    std::string c;
    bool first = true;
    while( b --> 0 ) {
        if( !first )
            c += '+';
        first = false;
        c += std::to_string(a);
    }
    std::cout << c;
}
8+8+8
http://coliru.stacked-crooked.com/a/7279315ab1d0759d
Topic archived. No new replies allowed.