Professional Documents
Culture Documents
DSA - Lab: Submitted To: Mam Rabia Arshad SUBMITTED BY: Muhammad Bilal
DSA - Lab: Submitted To: Mam Rabia Arshad SUBMITTED BY: Muhammad Bilal
Tasks_lab3
#include<iostream>
/* Options -- Menu */
Menu:
cout<<"\n 1) Insertion";
cout<<"\n 2) Deletion";
int option;
cout<<"\n\n\t Select any Option --> ";
cin>>option;
switch (option)
{ /* Case 1 -- Insertion */
case 1:
int newElement,position,done;
cout<<"\n Insert a New Element: ";
cin>>newElement;
cout<<"\n Position of New Element: ";
cin>>position;
done = insert(arr,capacity,size,newElement,position);
if(done==-1)
{
cout<<"\n Array Size is Greater than its Capacity";
exit(0);
}
else
{
size++;
printArray(arr,size);
}
break;
/* Case 2 -- Deletion */
case 2:
if(size==0)
{
cout<<"\n\t\t\t\t Array is Empty -- Make sure that your Array is not
Empty"<<endl;
goto Start;
}
else
{
int delElement;
cout << "\n Enter the Element to be Deleted: ";
cin >> delElement;
find_Delete(arr,size,delElement);
size--;
printArray(arr,size);
}
break;
default:
cout<<"\n\t\t\t\t Invalid Choice -- Make Right Choice"<<endl;
goto Menu;
}
goto Menu;
return 0;
}
Output:
Exercise #1
#include<iostream>
int n;
cout << "\n Enter the Size 2nd of Array: ";
cin >> n;
int B[n];
cout << "\n Enter " << n << " Elements: ";
for (int i = 0; i < n; i++)
cin >> B[i];
mergeArrays(A,B,m,n);
return 0;
}
Output: