Write the definition of a function named swapints that is passed two int reference parameters. The function returns nothing but exchanges the values of the two variables. So, if j and k have (respectively) the values 15 and 23, and the invocation swapints(j,k) is made, then upon return, the values of j and k will be 23 and 15 respectively.

Respuesta :

Answer:

void swapints(int *j,int *k)//Function definition.

{

   *j=*j+*k-(*k=*j); //value swapping.

}

swapints(&j,&k);//call the function.

Explanation:

  • The above function definition takes the address of j and k variables which is stored on the pointer variable j and k.
  • Then the pointer variable uses the j and k value for the above expression, and the user does not need to return the value of j and k.
  • But when the user prints the value of the j and k variable, then he gets the swapping value of the j and k variable.
  • The user needs to know that the "int j" is a normal variable, but "int *j" is a pointer variable that is used to take the address of j variable.