Header Ads Widget

Responsive Advertisement

Insert A Element at the End of an Array


 

#include<stdio.h>
int main ()
{
    int n,loc,ele;
    int arr [100];
    printf("Enter The Number : ");
    scanf("%d",&n);
    for(int i = 0; i<n; i++) {
        printf("Enter Number at Location %d : ",i);
        scanf("%d",&arr[i]);
    }

    printf("You Enter : ");
    for(int i =0 ; i<n; i++) {
        printf("%d ",arr[i]);
    }
    printf("\n");
    printf("Enter the Element To be Stored at the End : ");
    scanf("%d",&ele);

    printf("\n");
    arr[n] = ele;
    printf("Element %d is Stored in %d Location. \n",ele,n);
    printf("\n");
    printf("The New Array is : ");
    for(int i=0; i<n+1; i++) {
        printf("%d ",arr[i]);
    }
    return 0 ;
}


Post a Comment

0 Comments