0% found this document useful (0 votes)
9 views5 pages

DSA-Lab Report 1

Uploaded by

safyankhan.ik804
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views5 pages

DSA-Lab Report 1

Uploaded by

safyankhan.ik804
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

NAME : MUHAMMAD SAFYAN

CLASS : BSSE(3rd)
ROLL NO : FL-249
SUBJECT : DSA LAB
LAB REPORT : 01
SUBMITTED TO : Mr. H.M. Adnan Asghar
------------------------------------------
Insertion Array:
#include <iostream>
using namespace std;
int main()
{
int arr[] = {5, 3, 7, 9};
int length = sizeof(arr) / sizeof(int);

int index;
cout << "Enter index number : ";
cin >> index;

while (index > length)


{
cout << "\nIndex not found! Please try again :\n";

int index;
cout << "Enter index number : ";
cin >> index;
}
int insertVal;
cout << "Enter value to insert : ";
cin >> insertVal;

for (int i = length - 1; i > index; i--)


{
arr[i] = arr[i - 1];
}
arr[index] = insertVal;

cout << "\nInsertion Array : ";


for (int i = 0; i < length; i++)
{
cout << arr[i] << " ";
}
return 0;
}

console(output):
Deletion Array:
#include <iostream>
using namespace std;

int main()
{
int arr[] = {5, 3, 6, 7, 9};
int length = sizeof(arr) / sizeof(int);

int index;
cout << "Enter index number : ";
cin >> index;

while (index > length)


{
cout << "\nIndex not found! Please try again :\n";

int index;
cout << "Enter index number : ";
cin >> index;
}
for (int i = index; i < length - 1; i++)
{
arr[i] = arr[i + 1];
}

cout << "\nDeletion Array : ";

for (int i = 0; i < length - 1; i++)


{
cout << arr[i] << " ";
}
return 0;
}

console(output):

You might also like