Program to add a new element in the array and display the array after adding element

Program

#include <stdio.h>
int main()
{
    printf("**************************************************************");
    printf("\n**************************************************************");
    printf("\n**       WAP for insertion into an array                    **");
    printf("\n**             Created by Sheetal Garg                      **");
    printf("\n**               Assistant Professor                        **");
    printf("\n**               Phone No:9467863365                        **");
    printf("\n**************************************************************");
    printf("\n**************************************************************\n");
    int n,i,a[5],no,pos;
    printf("Enter no. of elements in the array\n");
    scanf("%d",&n);
    printf("enter array elements");
    for(i=0;i<n;i++)
    scanf("%d",&a[i]);
    printf("\nThe array elements before insertion are\n");
    for(i=0; i<n; i++)
    printf("%d\n",a[i]);
    printf("Enter new number to insert ");
    scanf("%d",&no);
    printf("enter the position for new number ");
    scanf("%d", &pos);
    for(i=n;i>=pos;i--)
    a[i]=a[i-1];
    a[pos-1]=no;
    printf("\nThe array elements after insertion are\n");
    for(i=0; i<n+1; i++)
    printf("%d\n",a[i]);
    return 0;
}

Output

**************************************************************
**************************************************************
**       WAP for insertion into an array                    **
**             Created by Sheetal Garg                      **
**               Assistant Professor                        **
**               Phone No:9467863365                        **
**************************************************************
**************************************************************
Enter no. of elements in the array
4
enter array elements
10
30
23
12

The array elements before insertion are
10
30
23
12
Enter new number to insert
11
enter the position for new number
2

The array elements after insertion are
10
11
30
23
12
error: You can only copy the programs code and output from this website. You are not allowed to copy anything else.