Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f2ae223

Browse files
committedAug 21, 2022
initial commit
0 parents  commit f2ae223

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed
 

‎array delete program.cpp

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
2+
//Copyright © 2022, Umar Habib, All rights reserved.
3+
4+
#include<iostream>
5+
#include<conio.h>
6+
using namespace std;
7+
int main()
8+
{
9+
int ar[100];
10+
int i,size,temp,loc=-1,del,n;
11+
ar:
12+
cout<<"\n\n Please enter the number of items in array = ";
13+
cin>>size;
14+
for(i=0;i<size;i++)
15+
{
16+
cout<<" \n Enter value in index "<<i<<" = ";
17+
cin>>ar[i];
18+
}
19+
delet:
20+
cout<<" \n\n Enter Delete number = ";
21+
again:
22+
cin>>del;
23+
for(i=0;i<size;i++)
24+
{
25+
if(ar[i]==del)
26+
{
27+
loc=i;
28+
temp=ar[i];
29+
ar[i]=ar[i+1];
30+
ar[i+1]=temp;
31+
}
32+
}
33+
if(loc==-1)
34+
{
35+
cout<<"\n you enter wrong number ";
36+
cout<<" \n\n Please again enter number = ";
37+
goto again;
38+
}
39+
else
40+
{
41+
size--;
42+
if(size==0)
43+
{
44+
cout<<" \t\t\t\t your element finish "<<endl;
45+
cout<<" \n\t\t\t Press 2 back to array declaration = ";
46+
n=getch();
47+
if(n==50)
48+
{
49+
system("cls");
50+
goto ar;
51+
}
52+
}
53+
else
54+
{
55+
cout<<"\n your deleted number is = "<<temp<<endl;
56+
cout<<"\n Array length = "<<size<<endl;
57+
cout<<"\n Remaining numbers in the array"<<endl;
58+
for(i=0;i<size;i++)
59+
{
60+
//cout<<" your number ";
61+
cout<<"\n\n\tValue in "<<i<<" index = "<<ar[i];
62+
}
63+
cout<<" \n\n If delete other number press 1\tand\tIf you want to back array declaration press 2 :";
64+
n=getch();
65+
if(n==49)
66+
{
67+
for(i=size;i>-2;i--)
68+
{
69+
loc=i;
70+
}
71+
goto delet;
72+
}
73+
else if(n==50)
74+
{
75+
system("cls");
76+
77+
goto ar;
78+
}
79+
}
80+
}
81+
getch();
82+
}

0 commit comments

Comments
 (0)
Please sign in to comment.