help with a question please.

Apr 7, 2014 at 8:08pm
hello, i need help with a C++ question.

Assume that all of the following functions calls return a value. of the four example lines list all that handle the return value in some way(i.e. use the return value in some way)? also describe how each returned value is used.

1.x=mynum(i,j);

2.cout<<testit(n,o,p);

3. maxval(v1, v2);

4.num=addit(d,e)+addit(f,g);
Apr 7, 2014 at 8:25pm
What exactly are you asking here?

1. The returned value is assigned to x (assuming mynum is non-void and x has a compatible type). Consider the following definition for mynum:
int mynum(int i,int j){ return i+j; }Now, when you run this:
int x=mynum(5,8);whatever is returned from the function is stored inside x; in this case, it can be shortened as int x=(5+8); or int x=13;

2. The function mechanism works the same; perhaps you are wondering what's with the << operator. That operator is used here as cout is a stream, and << inputs the value returned by testit(n,o,p); to the stream. You should read this for further info: http://www.cprogramming.com/tutorial/c++-iostreams.html

3. As long as you're not doing anything with the value returned by the function, it is lost.

4. This is just like case 1, except that the values returned by the function are used to form a more complex expression.
Apr 7, 2014 at 8:30pm
thanks, i was stumped on this question for a chapter review im doing. i said the samething to my self what exactly is it asking?... but thanks for your input and i will research the link you posted.
Apr 7, 2014 at 8:36pm
Well, simply put, the only returned value that's not handled is the third case.
Topic archived. No new replies allowed.