#include<stdio.h>
int main()
{
int array[100];
int i,j,n,index;
printf("Please Enter The array size: ");
scanf("%d",&n);
printf("
Please Enter %d elements of the array:
",n);
for(i=0; i<n; i++)
{
scanf("%d",&array[i]);
}
printf("
Please enter the index you want to replace: ");
scanf("%d",&index);
printf("
Please enter the number in %d index: ",index);
scanf("%d",&array[index]); ///saving new value in the same index.
printf("
Your Edited array is: ");
for(i=0; i<n; i++)
{
printf("%d ",array[i]);
}
printf("
");
return 0;
}
Output
Please Enter The array size:5
Please Enter 5 elements of the array: 12 54 3 12 8
Please enter the index you want to replace:3
Please enter the number in 3 index:65
Your Edited array is:12 54 3 65 8
Add your comment