Algorithm Question

Algorithm Question

The following statement calls a function named half. The half function returns a value that is half that of the argument. Write the function.

result = half(number)


My answer is

void half(double number / 2)


(I am not very good at this but I am trying my best)
Thanks in advance
Last edited on
More like this -

1
2
3
4
double half(double number)
{
    return (number / 2);
}
Last edited on
double half(double number);
No idea why I had it as void lol. I edited my post, thanks.
I'm just curious. How long have you been doing c++ programming? I am in my 2nd semester and I don't feel like I am ever going to catch on.
Started around the 20th of January. Had C for 2 months, then c++ for about the same (course only ended 2 weeks ago). You have to study and program at home as well, dont forget that. The internet is a very powerful resources and has basically all you need, so use it to your advantage. Find small projects to work on, like these for example, are quite fantastic for beginners -
http://www.cplusplus.com/forum/articles/12974/

Try your hardest, think outside the box, if you're completely stuck, use google to find your answer. Goodluck^^
Topic archived. No new replies allowed.