1. ## while

hi guys. im having a hard time figuring this out. could someone help me please?
How could I write the code for

Product of a & b with the use of addition operator only.

Thanks.

2. What have you tried?

3. Originally Posted by laserlight
What have you tried?
Honestly, I dont know what to do.

4. Have you not learned anything from posting here in the past? You need to show some effort, this seems to be a recurring problem. Did you learn how to count yet?

5. I presume a and b are only expected to be non-negative integers. So, choose some such values, substitute and then figure out how you would express that product as addition.

6. Thank you.

7. Originally Posted by bummielove
Product of a & b with the use of addition operator only.
Originally Posted by laserlight
So, choose some such values, substitute and then figure out how you would express that product as addition.
Originally Posted by bummielove
Thank you.
Laser: Your problem solving skills continue to amaze me.

8. Originally Posted by laserlight
I presume a and b are only expected to be non-negative integers. So, choose some such values, substitute and then figure out how you would express that product as addition.
Code:
```while(x<=b)
{
e1=e1+a;
x++;
}

for(x=1;x<=a;x++)
e2=e2*x;
for(x=1;x<=b;x++)
e3=e3*a;
if(b>0)```

9. I see '*' in that code, which you were forbidden to use, no?

You need to regress back to when you were eight years old and learning what multiplication was for the first time.

10. So, where did you take that code from? I would like to point out a couple of things:

1. This code has nothing to do with your problem.
2. Do not just post random code and then expect someone to post the correct code for you.

11. He is likely hoping Common Tator posts a good answer again.

Tim S.

12. @OP: Try this. Write down, in words, the steps you would use to solve this problem. Then share it with us. Then some of us might begin to help you turn it into code.

If you can't write it down in words for us, then this is actually a math-related problem and not a program-related problem.

13. Originally Posted by stahta01
He is likely hoping Common Tator posts a good answer again.
Tim S.
Lol......yeah he probably is. Well, let's see:

Common Tater: DO NOT POST A SOLUTION

14. Originally Posted by Matticus
@OP: Try this. Write down, in words, the steps you would use to solve this problem. Then share it with us. Then some of us might begin to help you turn it into code.

If you can't write it down in words for us, then this is actually a math-related problem and not a program-related problem.
so for example, a=3 and b =2
ans = 3+3.
My problem is how to begin the loop.

15. You have a concrete example, but an example is not an algorithm. Go back to a and b. How would you express a * b using addition, in words?