-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharray delete program.cpp
82 lines (79 loc) · 1.36 KB
/
array delete program.cpp
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
//Copyright © 2022, Umar Habib, All rights reserved.
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int ar[100];
int i,size,temp,loc=-1,del,n;
ar:
cout<<"\n\n Please enter the number of items in array = ";
cin>>size;
for(i=0;i<size;i++)
{
cout<<" \n Enter value in index "<<i<<" = ";
cin>>ar[i];
}
delet:
cout<<" \n\n Enter Delete number = ";
again:
cin>>del;
for(i=0;i<size;i++)
{
if(ar[i]==del)
{
loc=i;
temp=ar[i];
ar[i]=ar[i+1];
ar[i+1]=temp;
}
}
if(loc==-1)
{
cout<<"\n you enter wrong number ";
cout<<" \n\n Please again enter number = ";
goto again;
}
else
{
size--;
if(size==0)
{
cout<<" \t\t\t\t your element finish "<<endl;
cout<<" \n\t\t\t Press 2 back to array declaration = ";
n=getch();
if(n==50)
{
system("cls");
goto ar;
}
}
else
{
cout<<"\n your deleted number is = "<<temp<<endl;
cout<<"\n Array length = "<<size<<endl;
cout<<"\n Remaining numbers in the array"<<endl;
for(i=0;i<size;i++)
{
//cout<<" your number ";
cout<<"\n\n\tValue in "<<i<<" index = "<<ar[i];
}
cout<<" \n\n If delete other number press 1\tand\tIf you want to back array declaration press 2 :";
n=getch();
if(n==49)
{
for(i=size;i>-2;i--)
{
loc=i;
}
goto delet;
}
else if(n==50)
{
system("cls");
goto ar;
}
}
}
getch();
}