Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
669 B
2
Indexable
Never
#include <stdio.h>

int main(){
	int item,size;
	
	
	printf("Enter the size of array : ");
	scanf("%d",&size);
	
	int arr[size];
	
	for(int i=0;i<size;i++){
		printf("Enter the element at index %d: ",i);   
		scanf("%d",&arr[i]);
	}
	
	
	printf("Enter the element you want to delete : ");
	scanf("%d",&item);
	
	//searching for element in array
	for(int i=0;i<4;i++){
		if(arr[i] == item){
			int index = i;
			
			//shifting of element in array 
			for(int j=index;j<4;j++){
			arr[j] = arr[j+1];
			}
			break;
		}
	}
	
	printf("Sorted array are :-\n");
	for(int i=0;i< size-1;i++){//
		printf("%d\n",arr[i]);
	}
		
	return 0;
}