C Program to delete the first element in the array

#include<stdio.h>
void read(int a[50],int n);
void display(int a[50],int n);
void delete_first(int a[50],int n);
int main()
{
    int a[50],n;
    printf("Enter the size of the array\n");
    scanf("%d",&n);
    printf("Enter the array elements\n");
    read(a,n);
    printf("The array elements are:\n");
    display(a,n);
    delete_first(a,n);
    printf("\nAfter deleting the first element\n");
    display(a,n-1);
}

void read(int a[50],int n)
{
    int i;
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
}

void display(int a[50],int n)
{
    int i;
    for(i=0;i<n;i++)
    {
        printf("%d\t",a[i]);
    }
}

void delete_first(int a[50],int n)
{
    int i;
    for(i=1;i<n;i++)
    {
        a[i-1]=a[i];
    }
}

Output:

C Program to delete the first element in the array

Comments