Question 2: Write down a function called getPolarity(), which receives a 1D array of size 10 as an argument. The function converts all positive values in the array to +1 and all negative values in the function to -1. However, this change should not be made into parameter array, and it should remain unchanged. Rather, a new array should be created and returned from the function containing the above changes to original array (Hint: Pointers). Note that the parameter array elements with 0 value will remain unchanged, i.e., they will still have the 0 value in the output array. Finally Display the values of both in parallel way. Your program should work as follows: Enter value 0 of 9: 15 Enter value I of 9: 89

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

Question 2: Write down a function called getPolarity(), which receives a ID array of size 10
as an argument. The function converts all positive values in the array to +1 and all negative
values in the function to -1. However, this change should not be made into parameter array,
and it should remain unchanged. Rather, a new array should be created and returned from the
function containing the above changes to original array (Hint: Pointers). Note that the
parameter array elements with 0 value will remain unchanged, i.e., they will still have the 0
value in the output array. Finally Display the values of both in parallel way. Your program
should work as follows:
Enter value 0 of 9: 15
Enter value 1 of 9: 89
Enter value 2 of 9: -12
Enter value 3 of 9: 56
Enter value 4 of 9: -46
Ву code C
Enter value 5 of 9: 0
Enter value 6 of 9: -102
Enter value 7 of 9:0
Enter value 8 of 9: 77
Enter value 9 of 9: -5
The Data Analysis
15 1
89
-12
56
-46
1
-1
-1
-102
-1
77
1
-5
-1
2 of 3
||
Transcribed Image Text:Question 2: Write down a function called getPolarity(), which receives a ID array of size 10 as an argument. The function converts all positive values in the array to +1 and all negative values in the function to -1. However, this change should not be made into parameter array, and it should remain unchanged. Rather, a new array should be created and returned from the function containing the above changes to original array (Hint: Pointers). Note that the parameter array elements with 0 value will remain unchanged, i.e., they will still have the 0 value in the output array. Finally Display the values of both in parallel way. Your program should work as follows: Enter value 0 of 9: 15 Enter value 1 of 9: 89 Enter value 2 of 9: -12 Enter value 3 of 9: 56 Enter value 4 of 9: -46 Ву code C Enter value 5 of 9: 0 Enter value 6 of 9: -102 Enter value 7 of 9:0 Enter value 8 of 9: 77 Enter value 9 of 9: -5 The Data Analysis 15 1 89 -12 56 -46 1 -1 -1 -102 -1 77 1 -5 -1 2 of 3 ||
Expert Solution
steps

Step by step

Solved in 3 steps with 2 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