-
Notifications
You must be signed in to change notification settings - Fork 82
/
Program17.cpp
55 lines (55 loc) · 900 Bytes
/
Program17.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
#include<iostream.h>
#include<conio.h>
void arr(int a[10],int n)
{
int b[10][10],i,j;
for(i=0;i<n;i++)
for(j=0;j<n;j++)
{
b[i][j]=a[i];
}
for(i=0;i<n;i++)
{
cout<<"\n";
for(j=0;j<n;j++)
{
cout<<b[i][j]<<" ";
}
}
}
void ins(int a[10],int n)
{
int s,i,j,r,temp;
cout<<"enter element and location";
cin>>s>>r;
for(i=n;i>r;i--)
a[i]=a[i-1];
a[r]=s;
for(i=0;i<=n;i++)
cout<<a[i]<<" ";
}
void main()
{
clrscr();
int i,n,a[10],ch;
char x='y';
while(x=='y'||x=='Y')
{
cout<<"enter limit";
cin>>n;
cout<<"enter array";
for(i=0;i<n;i++)
cin>>a[i];
cout<<"menu \n1 Assign to 2D array \n2 Insert an element";
cin>>ch;
if(ch==1)
arr(a,n);
else if(ch==2)
ins(a,n);
else
cout<<"invalid choice";
cout<<"\nDo you want to continue?";
cin>>x;
}
getch();
}