Question: Requirements: You must use pointers to process all arrays. Part I : Required Code a C function that accepts pointers to two arrays of integers
Requirements: You must use pointers to process all arrays.
Part I : Required
- Code a C function that accepts pointers to two arrays of integers and their respective sizes. This function should check and count how many matchings entries in both arrays and return the count back to main for display. (important! Matchings entries do not have to be located in the same position and you are required to assume that the two arrays are of different sizesalso assume no duplicate within either arrays)
- Code a C function that accepts a pointer to an array of characters and its size. This function should invert the order of the array without the use of a second array.
Example: {e, r, t, m} becomes {m, t, r, e}
- Code a C function that accepts a pointer to an array of integers and its size. This function should replace any entrt that is divisible by 3 by a randomly generated integer that is not divisible by 3. This function should count how many instances of replacement occurred. display the array before and after and return that count back to main to display.
Part II: Extra credits:
XC1- Code a C function that accepts a pointer to an array of integers and its size and move from the array all even numbers to a different array and all odd numbers to another array (Hint! Malloc())
Display the original array. The array with even entries and array with odd entries.
XC2 Code a C function that accepts a pointer to an empty array of integers and its size. This function should generate random even integers to store in even position in the array and generate random odd integers to store in odd position in the array. Your function should print the content of the array.
Using the following template:
#include #include /* Author: Date: Description: */ //Add all needed functions' prototype here int main() { //declare all needed arrays and hard code their content for each questions //code all needed variables //prepare all pointers int selection = 0; while (selection != 6) { system("cls"); printf(" -1-Question 1 " "-2-Question 2 " "-3-Question 3 " "-4-XC1 " "-5-XC2 " "-6-Quit testing questions" "===>Select option 1 through 5 to test your code:"); scanf("%d", &selection); switch(selection) { case 1: QuestionOne(); //recode accordingly break; case 2: QuestionTwo(); //recode accordingly break; case 3: QuestionThree(); //recode accordingly break; case 4: XC_One(); //recode accordingly break; case 5: XC_Two(); //recode accordingly break; case 6: break; //user decides to quit default: { printf("Invalid selection!...hit any key to go back to menu"); getch(); }//end break;
}//end switch selection }//end while system("cls"); printf("Testing ended! \t\t\t"); return 0; }//end main //=============================================== void QuestionOne() //update accordingly { printf("this is question 1 area...delete this printf and the getch() when done...any key to continue"); getch(); }//end QuestionOne //================================================ void QuestionTwo() //update accordingly { printf("this is question 2 area...delete this printf and the getch() when done...any key to continue"); getch(); }//end QuestionTwo //================================================ void QuestionThree() //update accordingly { printf("this is question 3 area...delete this printf and the getch() when done...any key to continue"); getch(); }//end QuestionTHree //================================================= void XC_One() //update accordingly { printf("this is question XC 1 area...delete this printf and the getch() when done...any key to continue"); getch(); }//end XC_One //================================================= void XC_Two() //update accordingly { printf("this is question XC 2 area...delete this printf and the getch() when done...any key to continue"); getch(); }//end XC_Two
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
