6.22 LAB: Swapping variables Define a function named SwapValues that takes four integers as parameters and swaps the first with the second, and the third with the fourth values. Then write a main program that reads four integers from input, calls function SwapValues() to swap the values, and prints the swapped values on a single line separated with spaces. Ex: If the input is: 3 8 2 4 function SwapValues() returns and the main program outputs: 8 3 4 2 The program must define and call a function: void SwapValues(int* userVal1, int* userVal2, int* userVal3, int* userVal4) Function SwapValues() swaps the values referenced by the parameters. #include /* Define your function here */ int main(void) { /* Type your code here. Your code must call the function. */ return 0; }
6.22 LAB: Swapping variables
Define a function named SwapValues that takes four integers as parameters and swaps the first with the second, and the third with the fourth values. Then write a main program that reads four integers from input, calls function SwapValues() to swap the values, and prints the swapped values on a single line separated with spaces.
Ex: If the input is:
3 8 2 4function SwapValues() returns and the main program outputs:
8 3 4 2The program must define and call a function:
void SwapValues(int* userVal1, int* userVal2, int* userVal3, int* userVal4)
Function SwapValues() swaps the values referenced by the parameters.
#include <stdio.h>
/* Define your function here */
int main(void) {
/* Type your code here. Your code must call the function. */
return 0;
}
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images