Quote Originally Posted by rocksteady View Post
Hello everyone,

I'm trying to write pseudocode for a function that uses repeated addition instead of multiplication. In other words, inputting 2 and 5 should return 10, using only addition.

So far, I've thought of using one of the inputted numbers as a counter, but I don't know how this would be useful without the multiplication operator. I have some code, but it doesn't address how I can get the sum. I really need help getting direction with this program. If it helps, I think we are expected to use a recursive function.
Good ideas, as far as the first sentence goes. I suppose you could use a recursive function for this. You could also use a circular saw to cut your fingernails. (In other words: way more tool than you actually need, and I suggest you only look that way if the assignment explicitly asks for it.)

Code:
#include <stdio.h>

float sum (float number1, float number2)
{
    float sum;            /* sum of the two input numbers */
    
    sum = ??;
    
    return (sum);
}
So, why sum? You don't want to return the sum (2+5=7, but you're supposed to return 10). Think back, way back, to the first time you ever saw multiplication. What is multiplication, and how does it relate to adding? When you answer that, you'll be much farther.

(PS: floats? Are you sure we aren't talking (unsigned) integers?)