Insert operation C++
Insert operation C++
![]() |
| Add caption |
#include<bits/stdc++.h>
using namespace std;
int main (){
int x;
cout<<"Enter array size : "<<endl;
cin >>x;
int a[x+1];
cout <<"Enter array element : "<<endl;
for(int i =0;i<x;i++){
cin>>a[i];
}
int n;
cout<<"Enter insert number : "<<endl;
cin>>n;
for(int i=x;i<x+1;i++){
a[i]=n;
}
for(int i=0;i<x+1;i++){
for(int j=0;j<x+1;j++){
if(a[j]>a[j+1]){
swap(a[j],a[j+1]);
}
}
}
cout<<"Insert Result : "<<endl;
for(int i=0;i<x+1;i++){
cout<<a[i]<<" ";
}
}

Comments
Post a Comment