Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Part 3 ( 3 5 points ) ! ! PLEASE SOLVE IT IN C LANGUAGE!! Implement the following function in skeleton code lab 1 part
Part pointsPLEASE SOLVE IT IN C LANGUAGE!!
Implement the following function in skeleton code labpartc:
Circularly shift elements of arr from right to left until sequence of values in
arr becomes the smallest considering all sequence of values obtained by circularly
shifting elements in arr.
void circularShiftUntilMinArrint arr int n;
You need to use circularShiftFromRightToLeft function and compareTwoArrays function
while implementing circularShiftUntilMinArr function.
Print out sum of the elements of two arrays one by one.
Assume that arr can have at most elements in it Hint: If you need to declare a local array in function
circularShiftUntilMinArr, you can set its size as
Your task in this part to fill in the missing function definitions in skeleton code labpartc
main function will stay as it is Sample Run:
Enter the number of elements:
Enter elements:
Array elements:
After circularShiftUntilMinArr:
Array elements:
Sum of original and shifted elements:
Element :
Element :
Element :
Element :
Element :
Element : Here is the skeleton code labpartc code structure: #include
#define SIZE
reads numbers from the standard input into arr,
and stores the number of read elements in the memory cell pointed to by nPtr
void readInputint arr int nPtr;
prints the elements in arrn
void printNumbersconst int arr int n;
Circularly shift elements of arr from right to left where last element of arr is
shifted the first position of arr.
Size of arr is n
void circularShiftFromRightToLeftint arr int n;
Let n be the minimum of n and n where n and n are the number of elements in
arr and arr respectively.
Compare corresponding elements of arr and arr at each of the first n positions.
If arr and arr has the same value in each position:
Return if n n
Return if n n
Return if n n
If arr has a larger value than arr considering the first position from the
beginning at which arr and arr have a different value:
Return
If arr has a smaller value than arr considering the first position from the
beginning at which arr and arr have a different value:
Return
int compareTwoArraysconst int arr const int arr int n int n;
Circularly shift elements of arr from right to left until sequence of values in
arr becomes the smallest considering all sequence of values obtained by circularly
shifting elements in arr.
void circularShiftUntilMinArrint arr int n;
int main
int arrSIZE;
int n;
readInputarr &n;
printNumbersarr n;
circularShiftUntilMinArrarr n;
printf
After circularShiftUntilMinArr:
;
printNumbersarr n;
Calculate the sum of the elements after shifting for two arrays
FILL HERE
return ;
void readInputint arr int nPtr
fill here
void printNumbersconst int arr int n
fill here
void circularShiftFromRightToLeftint arr int n
fill here
int compareTwoArraysconst int arr const int arr int n int n
fill here
void circularShiftUntilMinArrint arr int n
fill here
Step 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