I need help with my C programming HW due tomorrow ... I will attach the code I have so far in a file, but what I need to do is to create 3 functions. One to get the input for the numbers, one to take the average of those numbers added together, and one to print out the results. I have tried for hours to create the functions, but idk how to get the code from each function to work together to run the program. THANK YOUUUUUU
Paypal me $10 and I will help you.
Paypal me $10 and I will let you help me \(*_*)/
Functions set up like this:
>One to get the input for the numbers
>void getNums(int * pArray){}
or if the number if ints isn't always 10, return the number of ints.
>int getNums(int * pArray){//return number of ints input}
>one to take the average of those numbers added together
>int aveNums(int * pArray){//return average}
or for a variable amount of numbers
>int aveNums(int * pArray, numOfNums){//return average}
>and one to print out the results.
>void printNums(int * pArray){}
or for a variable amount of numbers
>void aveNums(int * pArray, numOfNums){}
>how to get the code from each function to work together to run the program.
in main():
>getNums(pArray);
>int average = (pArray);
>printNums(pArray);
or if variable number of ints,
>int numOfInts = getNums(pArray);
>int average = aveNums(pArray, numOfInts);
>printNums(pArray, numOfInts);
optional for variable length array:
Instead of returning and using numOfInts for a variable length of ints, you could initialize the array to nulls then iterate through the ints until null is found.
>>301151
>or if the number if ints isn't always 10, return the number of ints.
You're not going to be doing that: void means "doesn't return anything".
>>301169
Try reading the very next line in that post.
>int getNums(int * pArray){//return number of ints input}
>>301177
You're still being a retard, because all that's doing is generating extra object code, and duplicating source code. Copy/paste code is a classic place for weird bugs to hide in, and a function that behaves differently depending on what you do with its return value is the kind of thing you'd see in the Malicious C Contest.
C doesn't care if you ignore the return value, and doesn't care if you don't assign it to anything. You don't need a void version of an int function, and shouldn't use it unless the function genuinely never returns anything.
Adding a void version of an existing function is a horrifying misuse of polymorphism.
>>301195
>Adding a void version of an existing function
>existing function
Where did you get that?
>or
one or the other depending on how anon was using it
>you're doing it wrong
>doesn't offer solutions
>>301208
>doesn't offer solutions
As I said, always return an int and let the caller decide whether or not to ignore it.
Providing an additional function that returns a void just in case the caller doesn't use the return value is asinine.
>>301208
OP: I need the code to function the way it does in the picture. I am using it to finish an example for my intro programming class.
is this what you want?
>https://pastebin.com/8TrxRV4t
also, MODS code tag pwease
>>301324
Yes thanks you so much :D