-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain (15).c
56 lines (48 loc) · 1.55 KB
/
main (15).c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/******************************************************************************
Online C Compiler.
Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <stdio.h>
int main()
{
int arr[50];
int ch, num , pos;
int size = 9;
while(1)
{
printf("---------Operations of Array---------\n");
printf("1. Insert\n");
printf("2. Delete\n");
printf("3. Traverse\n");
printf("4. Exit\n");
printf("Enter your choice: \n");
scanf("%d" , &ch);
switch(ch)
{
case 1: printf("Enter the number of elements you want to insert: ");
scanf("%d" , &num);
printf("Enter elements you want to insert:");
for(int i = 0; i < num ; i ++)
{
scanf("%d" , &arr[i]);
}
break;
case 2: printf("Enter the position you want to delete: ");
scanf("%d" , &pos);
for(int i = pos - 1 ; i < size - 1 ; i++)
{
arr[i] = arr[i+1];
} size--;
break;
case 3: for(int i =0; i < size ; i++)
{
printf("%d\t" , arr[i]);
}
break;
case 4: exit(0);
break;
default: printf("Invalid Choice!");
}
}
}