Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

C programming Project 4, Program Design 1. (50 points) Write a program arraysl.c that checks if two integer arrays are different by one and only

C programming image text in transcribed
Project 4, Program Design 1. (50 points) Write a program arraysl.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, retums 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 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 result

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions