AedenCak3

C program that deletes the first element in an array

Dec 7th, 2021
504
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3.  
  4. int main()
  5. {
  6.     int arr[100],size,i;
  7.  
  8.  
  9.     printf("Enter the size of the array : ");
  10.     scanf("%d", &size);
  11.     printf("Enter the elements in the array : ");
  12.     for(i=0; i<size; i++)
  13.     {
  14.         scanf("%d", &arr[i]);
  15.     }
  16.  
  17.     for(i=0; i<size-1; i++)
  18.     {
  19.         arr[i] = arr[i+1];
  20.     }
  21.     size--;
  22.  
  23.     printf("After deleting the first element  : ");
  24.    
  25.    
  26.     for(i=0; i<size; i++)
  27.     {
  28.         printf("%d\n", arr[i]);
  29.     }
  30.    
  31.    
  32.     return 0;
  33. }
  34.  
RAW Paste Data