- Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSimpleMenuUsingBasicArray.cpp
More file actions
Latest commit
97 lines (65 loc) · 1.39 KB
/
Copy pathSimpleMenuUsingBasicArray.cpp
File metadata and controls
97 lines (65 loc) · 1.39 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#include<stdio.h>
#include<stdlib.h>
intmain(){
int menu;
int n = 0;
int arr[10];
do {
system ("cls");
printf ("Menuuuuuu\n");
if (n == 0 || n == 1) printf ("There is %d data in the array\n", n);
elseprintf ("There are %d data in the array\n", n);
puts("---------------");
puts("1. Push");
puts("2. Pop");
puts ("3. View Data");
puts("4. Exit");
printf ("\n>> ");
scanf ("%d", &menu);
if (menu == 1) {
system ("cls");
printf ("Input value: ");
scanf ("%d", &arr[n]);
n++;
}
elseif (menu == 2) {
system ("cls");
int del;
printf ("Input index: ");
scanf ("%d", &del);
if (n == 0){
printf ("There is no data yet!\n");
getchar();
}
if (del <= n-1 && n != 0){
for (int i = del; i <= n; i++){
if (del == n) arr[i] = 0;
else arr[i] = arr[i+1];
}
n--;
}
else {
printf ("There is no such data with that index!\n");
printf ("Press enter to continue...");
getchar();
getchar();
}
}
elseif (menu == 3){
system("cls");
if (n == 0) printf ("No data...\n");
else {
for (int i = 0; i < n; i++){
printf ("%d ", arr[i]);
}
}
printf ("\n\nPress enter to continue...");
getchar();
getchar();
}
elsesystem("cls");
}
while (menu != 4);
printf ("Thanks :))\n");
return0;
}