C-programming I need a correct and well done answer ASAP, please. Thank you.

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

C-programming I need a correct and well done answer ASAP, please. Thank you.

Post by answerhappygod »

C-programming
I need a correct and well done answer ASAP, please.
Thank you.
C Programming I Need A Correct And Well Done Answer Asap Please Thank You 1
C Programming I Need A Correct And Well Done Answer Asap Please Thank You 1 (45.06 KiB) Viewed 45 times
C Programming I Need A Correct And Well Done Answer Asap Please Thank You 2
C Programming I Need A Correct And Well Done Answer Asap Please Thank You 2 (63.88 KiB) Viewed 45 times
C Programming I Need A Correct And Well Done Answer Asap Please Thank You 3
C Programming I Need A Correct And Well Done Answer Asap Please Thank You 3 (36.38 KiB) Viewed 45 times
Arrays in C Implement a function that compares each pair of elements of two integer arrays, and swaps them if the value of element of arr2 is smaller than the value of element of arri. The function gets two integer arrays of n elements. It goes through all the elements of both arrays and compares the element of arr1 with the element of arr2. If arr2 element has a smaller value than arri, the function swaps the element values between the two arrays. So, after running the function, arr1 contains the smaller numbers and arr2 contains the larger numbers in each pair. Hint A function for swapping two values is provided in the template.

C main.c x Exam Question > C main.c > ... 1 #include <ctype.h> 2 #include <stdio.h> 3 #include <stdlib.h> 4. #include <string.h> 5 #include <time.h> 6 7 /** 8 * \brief Swaps the integer value of the memory pointed to by 'a' with the integer value of the memory pointed to by 'b'. * * * 9 10 11 12 13 14 15 16 17 18 * \param a A pointer of the memory of which value to be swapped. \param b A pointer of the memory of which value to be swapped. */ void swap(int* a, int* b) { int temp = *a; *a *b; *b temp; } 19 /** 20 21 22 23 \brief Compares each pair of elements of two integer arrays, and swaps them if the value of element of arr2 is smaller than the value of element of arri. 24 25 n * 26 27 28 29 30 31 32 * \details This function gets two integer arrays of n elements. It goes through all the elements of both arrays and compares the element of arri with the element of arr2. If arr2 element has a smaller value than arri, the function swaps the element values between the two arrays. So, after running the function, arr1 contains the smaller numbers and arr2 contains the larger numbers in each pair. 33 * 34 * \param arri The integer array that will have the smaller of values. \param arr2 The integer array that will have the larger of values. * \param n The number of elements in both of the arrays. 35 36 * 37 * \note A function for swapping two values is provided above.

38 39 40 89mmmm 如 41 42 \note In your implementation, do not write to stdout to check the functionality. You should use my_tests function to print and check the functionality of your implementation. */ void pair_array_min(int* arri, int* arr2, unsigned int n) { //TODO: implement the function here! } 43 44 45 46 47 * 48 /** \brief conducts the tests for your implementation. * 49 * 50 51 52 * \details you are strongly encouraged to test your implementation using this function. Try to create at least three test cases to check * whether your function implementation is correct. * 53 54 55 */ void my_tests(void) { // You can write your own test code here. } 56 57 58 59 60 61 int main(void) { /* You may implement your own tests in my_tests function */ my_tests(); } 62
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply