Write a program to swap the values of 2 arrays using pointers. Create a function (void inputArray) to input the elements of the arrays. For your function, Receive parameter of pointer to an array from main • fill the array by using the pointer parameter Sample void inputArray(int *arr) for (..?..) scanf("%d", arr..); Modify the sample above, especially the bolded parts, [refer part 5 Array and Pointers] In your main, create array and pass it to inputArray() to fill up the elements • Printout the array to check whether elements have been input from function • Use a for loop, temp variable and pointers to swap the elements of the arrays. Pseudocode

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%
Write a program to swap the values of 2 arrays using pointers. Create a function (void
inputArray) to input the elements of the arrays.
For your function,
Receive parameter of pointer to an array from main
- fill the array by using the pointer parameter
Sample
void inputArray(int *arr)
for (...?..)
{
scanf("%d", arr.);
Modify the sample above, especially the bolded parts, (refer part 5 Array and Pointers]
In your main,
create array and pass it to inputArray() to fill up the elements
· Printout the array to check whether elements have been input from function
Use a for loop, temp variable and pointers to swap the elements of the arrays.
Pseudocode
int main ()
int size = 10;
int i, temp;
int arri[size);
int arr2[size);
input array for arr1 and arr2 using inputArray()
print arrays
for (loop)
temp = *(arr1_current_space);
*(arri_current_space) = *(arr2_current_space);
*(arr2_current_space) = temp;
print arrays
Modify the pseudocode above, especially all the bolded parts.
The swapping part you need to use pointer to go to current spaces in arrl and arr2 because
your initial pointer is at start of array. [refer part 5 Array and Pointers]
Transcribed Image Text:Write a program to swap the values of 2 arrays using pointers. Create a function (void inputArray) to input the elements of the arrays. For your function, Receive parameter of pointer to an array from main - fill the array by using the pointer parameter Sample void inputArray(int *arr) for (...?..) { scanf("%d", arr.); Modify the sample above, especially the bolded parts, (refer part 5 Array and Pointers] In your main, create array and pass it to inputArray() to fill up the elements · Printout the array to check whether elements have been input from function Use a for loop, temp variable and pointers to swap the elements of the arrays. Pseudocode int main () int size = 10; int i, temp; int arri[size); int arr2[size); input array for arr1 and arr2 using inputArray() print arrays for (loop) temp = *(arr1_current_space); *(arri_current_space) = *(arr2_current_space); *(arr2_current_space) = temp; print arrays Modify the pseudocode above, especially all the bolded parts. The swapping part you need to use pointer to go to current spaces in arrl and arr2 because your initial pointer is at start of array. [refer part 5 Array and Pointers]
Sample output
Before Swap:
Аrгay: 1
8
8.
5
6
54
5
68
6
Array: 2
After Swap:
5
65
4
2
Аггау: 2
5
65
68
6
4
2
Array: 1
8
5
6
54
Transcribed Image Text:Sample output Before Swap: Аrгay: 1 8 8. 5 6 54 5 68 6 Array: 2 After Swap: 5 65 4 2 Аггау: 2 5 65 68 6 4 2 Array: 1 8 5 6 54
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY