clinically-proven

aaaa

Feb 5th, 2021
1,148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.62 KB | None | 0 0
  1. #include <stdio.h>
  2. int main()
  3. {
  4.    int array[100], position, c, n;
  5.    printf("Enter number of elements in array\n");
  6.    scanf("%d", &n);
  7.    printf("Enter %d elements\n", n);
  8.    for (c = 0; c < n; c++)
  9.       scanf("%d", &array[c]);
  10.    printf("Enter the location where you wish to delete element\n");
  11.    scanf("%d", &position);
  12.    if (position >= n+1)
  13.       printf("Deletion not possible.\n");
  14.    else
  15.    {
  16.       for (c = position - 1; c < n - 1; c++)
  17.          array[c] = array[c+1];
  18.       printf("Resultant array:\n");
  19.       for (c = 0; c < n - 1; c++)
  20.          printf("%d\n", array[c]);
  21.    }
  22.    return 0;
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment