BSEM-F19-200 (Muhammad Muneeb
BSEM-F19-200 (Muhammad Muneeb
BSEM-F19-200 (Muhammad Muneeb
Section: 3D
Assignment #1
Q1: Using the concept of arrays take the maximum 20 random values from user. After that write the
function ascending which convert the given values into ascending values same as descending vice
versa. After that delete the number from array and search the number of particular location.
#include <iostream>
#include<conio.h>
int A[20];
int del;
int temp;
void Display_Array()
cout<<A[i]<<" ";
cout<<endl;
void Ascending_order()
if(A[j]>A[j+1])
{
temp = A[j];
A[j] = A[j+1];
A[j+1] = temp;
void Descending_order()
if(A[j]<A[j+1])
temp = A[j];
A[j] = A[j+1];
A[j+1] = temp;
void delete_element()
{
int size,count=0;
cin>>size;
cin>>A[i];
cin>>del;
if(A[i]==del)
A[j]=A[j+1];
count++;
break;
}
cout<<"Element deleted successfully..!!\n";
cout<<A[i]<<" ";
cout<<endl;
int main()
cin>>A[i];
system("cls");
Display_Array();
Ascending_order();
Display_Array();
Descending_order();
Display_Array();
delete_element();
getch();
#include <iostream>
#include<conio.h>
#define SIZE 5
char A[SIZE];
char value;
bool isempty()
if (top == -1)
return true;
else
return false;
if (top == SIZE - 1)
cout<<"****************"<<endl;
cout<<"****************"<<endl;
else
top++;
A[top] = value;
void pop()
if (isempty())
cout<<"****************"<<endl;
cout<<"****************"<<endl;
else
top--;
}
void showTop()
if (isempty())
cout<<"****************"<<endl;
cout<<"****************"<<endl;
else
cout<<"****************"<<endl;
cout<<"****************"<<endl;
void displaystack()
if (isempty())
cout<<"****************"<<endl;
cout << "Stack is empty\n";
cout<<"****************"<<endl;
else
cout<<"****************"<<endl;
cout<<"****************"<<endl;
int main()
int choice;
int flag=1;
while(flag==1)
cout<<"..............Stack................"<<endl;
cin>>choice;
system("CLS");
switch(choice)
case 1:
cin>>value;
push(value);
break;
case 2:
pop();
break;
case 3:
showTop();
break;
case 4:
displaystack();
break;
case 5:
flag=0;
break;
getch();
#include <iostream>
#include<conio.h>
#define SIZE 5
int A[SIZE];
int value;
bool isempty()
return true;
else
return false;
}
//function to insert element in queue
if (rear == SIZE - 1)
cout<<"****************"<<endl;
cout<<"****************"<<endl;
else
if (front == -1)
front = 0;
rear++;
A[rear] = value;
void dequeue()
int sum_dq;
if (isempty())
cout<<"****************"<<endl;
cout<<"****************"<<endl;
}
else
if (front == rear)
else
front++;
void showfront()
if (isempty())
cout<<"****************"<<endl;
cout<<"****************"<<endl;
else
cout<<"****************"<<endl;
cout<<"****************"<<endl;
}
//function to display elements of the queue
void displayQueue()
if (isempty())
cout<<"****************"<<endl;
cout<<"****************"<<endl;
else
cout<<"****************"<<endl;
cout<<"****************"<<endl;
int main()
int choice;
int flag=1;
while(flag==1)
cout<<"..............Queue................"<<endl;
cin>>choice;
system("CLS");
switch(choice)
case 1:
cin>>value;
enqueue(value);
break;
case 2:
dequeue();
break;
case 3:
showfront();
break;
case 4:
{
displayQueue();
break;
case 5:
flag=0;
break;
getch();