Max not displayed when code executed | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Max not displayed when code executed

Here I have written a code that finds the maximum number out of three integers using user defined Function, but the problem is that when I execute it, it doesn't display the maximum number. Can someone help me out? Please and thank you. #include <iostream> int max(int n1, int n2, int n3); using namespace std; int main() { int n1,n2,n3,i=1; while (i>0) { cout<<"enter first number:"<<endl; cin>>n1; cout<<"enter second number:"<<endl; cin>>n2; cout<<"enter third number:"<<endl; cin>>n3; max( n1, n2, n3); cout<<endl; cout<<"do you want to enter three integer numbers again (press a negative value to exit)"<<endl; cin>>i; } return 0; } int max(int n1, int n2, int n3) { int max; if (n1>n2 && n1>n3) max=n1; else if (n2>n1 && n2>n3) max=n2; else max=n3; return max; }

3rd Mar 2018, 4:21 PM
Inky
4 Answers
+ 1
you should share the code itself,not copy all its contents in a question
3rd Mar 2018, 4:22 PM
᠌᠌Brains[Abidemi]
᠌᠌Brains[Abidemi] - avatar
0
Ohkay and how do I do that? Like how do I upload the file. (New here, so still figuring out stuff.)
3rd Mar 2018, 4:24 PM
Inky
0
Ohh, that makes sense. Thanks! Where else can I paste my code? :/
3rd Mar 2018, 7:04 PM
Inky
0
Okay thanks.
4th Mar 2018, 12:07 PM
Inky