Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Using C language Compile both programs with Wall. Wall shows the warnings by the compiler. Be sure it compiles on student cluster with no errors
Using C language
Compile both programs with Wall. Wall shows the warnings by the compiler. Be sure it compiles on student cluster with no errors and no warnings.
gcc Wall arrays1.c
gcc Wall arrays2.c
Project 4, Program Design 1. (50 points) Write a program arrays1.c that checks if two integer arrays are different by one and only one element when compared element by element (first element with first element, second with second, and so on) and displays the elements that are different. The program asks the user to enter the size of the arrays and then the elements of the arrays. Sample input/output #1: Enter the length of the array: 5 Enter the elements of the first array: -12 0 4 2 36 Enter the elements of the second array: -12 0 4 5 36 Output: The arrays are different by one element, 2 and 5. Sample input/output #2: Enter the length of the array: 4 Enter the elements of the first array: -12 0 4 36 Enter the elements of the second array: -12 0 4 36 Output: The arrays are NOT different by one element Sample input/output #3: Enter the length of the array: 5 Enter the elements of the first array: 5 0 4 2 36 Enter the elements of the second array: -12 0 4 5 36 Output: The arrays are NOT different by one element 1) Include and implement the following function in the program. Do not modify the function prototype. int one_element different (int *al, int *a, int n, int *elementi, int *element2); The function takes two integer array parameter al and a 2 of size n. The function returns 1 if the two arrays are different one and only one element, returns 0 otherwise. elementi and element 2 are integer pointers pointing to the variables in the main function that store the elements of the array 1 and array 2 where the elements are different. The function should use pointer arithmetic - not subscripting-to visit array elements. In other words, eliminate the loop index variables and all use of the l operator in the function. 2) In the main function, ask the user to enter the size of the arrays, declare the arrays, and then ask the user to enter the elements of the two arrays. The main function calls one_element_different function, and displays the resultStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started