Exp 2
Exp 2
Aim - Write a C program to insert the element at the specific position of array.
Description
An array is a data structure that allows you to store multiple elements of the same type in a contiguo
us block of memory.
Algo-
1. Input:
2. Check Validity:
3. Shift Elements:
4. Insert Element:
5. Update Size:
• Increment size n by 1
6. Output:
Code
#include <stdio.h>
int main() {
scanf("%d", &n);
int arr[n + 1]; // Array with an extra space for the new element
printf("Enter elements:\n");
scanf("%d", &arr[i]);
scanf("%d", &elem);
scanf("%d", &pos);
return 0;
Output:
Enter elements:
10 20 30 40
10 20 25 30 40