DSA 1
DSA 1
AIDS/B/67
#define MAX_SIZE
100
return;
return;
++;
if (*size == 0) {
return;
}
n"); return;
(*size)--;
if (size == 0) {
printf("Array is empty.\
n"); return;
printf("Array elements:
+) {
printf("\n");
int main() {
int
arr[MAX_SIZE];
int size = 0;
scanf("%d", &choice);
switch (choice)
{ case 1:
scanf("%d", &element);
scanf("%d", &position);
position); break;
case 2:
scanf("%d", &position);
deleteAtPosition(arr, &size,
position); break;
case 3:
displayArray(arr,
size); break;
case 4:
n"); return 0;
default:
printf("Invalid choice. Please try again.\n");
return 0;
Output:
Conclusion:
This C program allows users to insert, delete, and display elements in an array using a menu-
driven approach. It ensures proper bounds checking and handles errors effectively. However, it is
limited by a fixed array size and can be improved with dynamic memory allocation.