#include<stdio.h> void display(int arr[], int n){ // Code for Traversal for (int i = 0; i < n; i++) { printf("%d ", arr[i]); } printf("\n"); } int indInsertion(int arr[], int size, int element, int capacity, int index){ // code for Insertion if(size>=capacity){ return -1; } for (int i = size-1; i >=index; i--) { arr[i+1] = arr[i]; } arr[index] = element; return 1; } void indDeletion(int arr[], int size, int index) { // code for Deletion for (int i = index; i < size-1; i++) { arr[i] = arr[i + 1]; } } int main(){ int arr[100] = {7, 8, 12, 27, 88}; int size = 5, element = 45, index=0; display(arr, size); // indInsertion(arr, size, element, 100, index); //size +=1; //display(arr, size); indDeletion(arr,size,index); size--; display(arr,size); return 0; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter