// Updating a value of an array
#include<stdio.h>


int main(){
    int n,i,p,v;
    printf("Enter length of array : ");
    scanf("%d",&n);
    int a[n];
    printf("\nEnter elements of the array : ");
    for(i=0;i<n;i++){
        scanf("%d ",&a[i]);
    }
    printf("\nEntered array is : ");
    for(i=0;i<n;i++){
        printf("%d ",a[i]);
    }
    printf("\nEnter the value and position you want to update : ");
    scanf("%d, %d",&p,&v);
    printf("\nPosition : %d and Value : %d ",p,v);
    for(i=n-1 ; i>(p+1) ; i--){
        a[i+1]=a[i];
    }
    a[p-1]=v;
    printf("\nEntered array is : ");
    for(i=0;i<n;i++){
        printf("%d ",a[i]);
    }
    
    
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: