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; }