i have a question why doesnt this work?

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445`` ``````#include "stdafx.h" #include #include #include #include #include #include "windows.h" #include using namespace std; double largest(int a, int b,int c); int a=2; int b=3; int c=10; int main() { cout<< "numbers to be checked are 2,3, and 10 "<< endl; largest(2,3,10); cout<< "the largest number is: "<< endl; system("pause"); return 0; } double largest(int a, int b,int c) { if (a>b&&a>c) { cout << a; return a; } else if (b>a&&b>c) { cout<< b; return b; } else { cout<< c; return c; } }``````
Last edited on
Hi, at first glance I notice your function largest is returning a double but is not being used.

At line 19 in your program you are returning a double but not doing anything with it, i assume you expect the output to be "the largest number is: largestnumber"

You could add the call to largest into the same line as line 20 and make it look something like
 `` `` ``cout << "the largest number is: " << largest(2,3,10) << endl;``

alternatively you could change line number 19 to store the largest value in a double and then use that in your statement on line 20. This can be accomplished like so

 ``12`` ``````double largest_value = largest(2,3,10); // line 19 cout << "the largset number is: " << largest_value << endl; // line 20 ``````
thanks a lot i had this on my final as a question and i didnt turn it in because of that ...... i guess every one makes mistakes. thanks anyways
Topic archived. No new replies allowed.