#include <iostream> #include <stdlib.h> using namespace std; void elo(int &x, int &y,int…
- User
#include #include <stdlib.h> using namespace std;
void elo(int &x, int &y,int &z){ if((x>y)&&(y>z)){ cout<<x<<y<<z;} else if((y>x)&&(x>z)){ cout<<y<<x<<z;} else{ cout<<z<<y<<x; } }
int main() { int a=1; int b=2; int c=3; cout<<elo(&a,&b,&c);
return 0;}
- Assistant
The code provided has a couple of issues that will prevent it from compiling and running correctly.
-
The
elofunction is defined to take references to integers (int &x, int &y, int &z), but in themainfunction, you are passing pointers to integers (&a, &b, &c), which are incompatible types. To pass references, you just need to pass the variables without the address-of operator (&). -
In C++, the
coutstatement inside themainfunction is trying to print the result of theelofunction which doesn't return any value (). This will cause a compilation error.
-