0
//a function that adds for a user

//prototype

int GetProduct(void);

int main (void)

    {
        int n = GetProduct();
        printf("It's %d\n", n);
    }

int GetProduct(void)
{
    printf("Integer please: ");
    int a = GetInt();
    printf("Another integer, please: ");
    int b = GetInt();
    int n = (a + b);
}

So after watching Week 2's Monday lecture, I practiced writing a couple functions like the one showcased in the lecture. However, I'm trying to make this particular function that adds for a user, but I keep getting error messages. Is my logic correct?

I really want to go to sleep, but this is keeping me up, lol. I'm extremely brand new to this programming thing, but I find myself enjoying it quite a bit. Regardless, I still find myself stumbling and pulling my hair out when I know I'm just making stupid mistakes.

Any insight would be greatly appreciated.

1

You need to return n; in your function. And btw, a+b is not the product :)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .