experimenting with a function

Currently, I am experimenting with this function.

// return of two values
#include
using namespace std;

void previousnext (int x, int& previous, int& next)
{
previous = x-1;
next = x+1;
}

int main ()
{
int x=150, y, z;
previousnext (x, y, z);
cout << “The previous value is ” << y << “, and the next value is ” << z <<”.\n”;
return 0;
}

You may want to read some explanation how it works.

Comments are closed.