#include <stdio.h>
int main() {
int ar[7] = {10, 20, 30, 40, 50}, i, pos, n;
printf("\nPrint Array");
for (i = 0; i < 5; i++) {
printf("\n%d", ar[i]);
}
printf("\nEnter position to insert:");
scanf("%d", &pos);
printf("\nEnter value:");
scanf("%d", &n);
// Validate position
if (pos < 0 || pos > 5) {
printf("\nInvalid position!");
return 1;
}
// Shift elements
for (i = 4; i >= pos; i--) {
ar[i + 1] = ar[i];
}
ar[pos] = n;
printf("\nPrint New Array");
for (i = 0; i < 6; i++) {
printf("\n%d", ar[i]);
}
return 0;
}