AedenCak3

C program to delete particular index in an array

Dec 6th, 2021
709
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.     int i,num;
  7.     printf("Enter the size of the arrays  :");
  8.     scanf("%d", &num);
  9.  
  10.     int arr1[num], arr2[num], arr3[num] ;
  11.  
  12.     printf("enter elements in the array1 : ");
  13.  
  14.     for(i=0; i<num ; i++)
  15.     {
  16.         scanf("%d", &arr1[i]);
  17.     }
  18.  
  19.     int k;
  20.     printf("enter the index to delete:" );
  21.     scanf("%d", &k);
  22.  
  23.     for (i=k ; i<num-1 ; i++)
  24.     {
  25.         arr1[i]=arr1[i+1];
  26.     }
  27.  
  28.     num=num-1 ;
  29.  
  30.     printf("Array after deleting the element : ");
  31.    
  32.  
  33.     for(i=0; i<num; i++)
  34.     {
  35.         printf("%d\t", arr1[i]);
  36.     }
  37.    
  38.    
  39.    
  40.     return 0;
  41.  
  42. }
RAW Paste Data