You are on page 1of 3

//SORTING OF AN ARRAY

#include<iostream>
using namespace std;

int main ()
{
int arr[10] = {2, 3, 4, 9, 7, 1, 6, 5, 0, 8};
int temp;
for (int j = 0; j<10; j++)
{
for(int i = 0; i<10; i++)
{
if (arr[i] > arr[i+1])
{
temp = arr[i];
arr[i]=arr[i+1];
arr[i+1] = temp;
}
}
}
cout << "{";
for(int i = 0; i<10; i++)
{
cout << arr[i] <<", ";
}
cout << "}";
return 0;
}
// DELETE ARRAY

#include<iostream>
using namespace std;

int main()
{
int size;
cout <<"enter the size of the array : ";
cin >> size;

int array [size];


cout << "Enter Array elements: \n";
for (int index = 0; index < size; index++)
{
cin >> array[index];
}
int position;
cout << " Enter the position you wanna delete :";
cin >> position;
position--;
for (int index = position; index<size; index++)
{
int temp = array[index];
array[index]=array[index+1];
array[index+1]=temp;
}
cout <<endl;
for (int index = 0; index<size-1; index++)
{
cout << array[index]<<" ";
}
return 0;
}
// INSERTION/INSERT

#include <iostream>
using namespace std;
int main()
{
int num[100];
int value;
int position;

cout <<" Enter the elements : ";


for ( int i=0; i<5; i++)
{
cin >> num[i];
}
cout << "enter the value to be inserted: ";
cin >> value;
cout << "enter the position : ";
cin >> position;
for(int i=0; i<position; i++)
{
num[position] = value;
}
for(int i= 0; i < 5; i++)
{
cout << num[i] << " ";
}
cout << endl;

return 0;

You might also like