Consider the following method:
Method Body:
void insertinArray(int num, int index){int i;if(index >= counter){NumAry[counter++] = num;return;}i = counter;while(i > index){NumAry[i] = NumAry[--i];}NumAry[index] = num;counter++;}
The above method takes a number and position from user and then stores that number at specific position in an array, Now I want some additional functionalities in this method that is if there is sorted array from 1 to 5 and user call this method and pass number=15 and index = 3, I want that the method prompts an error in this case asking the user that doing this the order of array will disturb, Would you like to continue? If the user continue it inserts the element at repective index and display a message that value inserted but order disturbed else it will terminate.
(Dont use pointers please)
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here