Declare a 1D array of n elements. Then input values in array in such a way that user only allowed to input into the last element. But if you always input value into the last element then the remaining array always remains empty. Therefore, we introduced a shifting method that shift each element to its neighboring element before entering the new element. Write a function Shift_Array () which takes the array as an argument and perform the element shifting process and then in main function input item at the end of the array. The functionally is explained below: 8 Array after 1st value 0 1 2 3 4 5 Index 8 12 Array after 2nd value 0 1 2 3 4 5 Index 8 12 2 Array after 3rd value 0 1 2 3 4 5 Index 8 12 2 13 Array after 4th value 0 1 2 3 4 5 Index 8 12 2 13 7 Array after 5th value 0 1 2 3 4 5 Index 8 12 2 13 7 19 Array after 6th value 0 1 2 3 4 5 Index
Write a program that execute first part if user press 1 and execute second part if user press 2.
• Recall the 1D array and functions concepts that we learned then write a program using those concepts. Declare a 1D array of n elements. Then input values in array in such a way that user only allowed to input into the last element. But if you always input value into the last element then the remaining array always remains empty. Therefore, we introduced a shifting method that shift each element to its neighboring element before entering the new element. Write a function Shift_Array () which takes the array as an argument and perform the element shifting process and then in main function input item at the end of the array. The functionally is explained below:
8
Array after 1st value
0
1
2
3
4
5
Index
8
12
Array after 2nd value
0
1
2
3
4
5
Index
8
12
2
Array after 3rd value
0
1
2
3
4
5
Index
8
12
2
13
Array after 4th value
0
1
2
3
4
5
Index
8
12
2
13
7
Array after 5th value
0
1
2
3
4
5
Index
8
12
2
13
7
19
Array after 6th value
0
1
2
3
4
5
Index
Step by step
Solved in 2 steps