booooooooooooooooty
booooooooooooooooty
booooooooooooooooty
Write a function RemoveVowels() that should remove all the vowels in the array. All array
operations should be done using pointers.
#include <iostream>
using namespace std;
return 0;
}
You are required to design a program which should allow creation of a dynamic array. User
should provide the size of array as input which should be in range of 1 to 20, when program is
executed. Further user will provide input for elements of array. For each element value to be
given as input should be in range of 0 to 12. Your program should calculate and display average
of all elements of this array. Further program should calculate and display the factorial of each
element of this array.
#include <iostream>
using namespace std;
int main() {
int size;
cout << "Enter " << size << " elements (each between 0 and 12):\n";
return 0;
}
Write a program which should contain three 2-dimensional dynamic arrays. For two arrays user
will provide the size and values of elements as input. Your program should assume each of
these arrays as matrices and should perform addition between two arrays for which user has
provided input values, your program should store results of addition in third array by using
nested loops. Your program should display the values of elements of third array which should
contain the results of addition
#include <iostream>
using namespace std;
int main() {
int rows, cols;
return 0;
}
#include <iostream>
using namespace std;
class MyList {
private:
int *items;
int size;
int pos;
public:
MyList() {
size = 0;
cout << "Enter size for array: ";
cin >> size;
items = new int[size];
pos = 0;
}
}
}
}
};
int main() {
MyList list;
int val = 0, loc = 0;
int ch = 0;
do {
cout << "Press 1 for Add value in sequence" << endl;
cout << "Press 2 for Retrieve value" << endl;
cout << "Press 3 for Add value anywhere" << endl;
cout << "Press 4 for Display" << endl;
cout << "Press 5 for Delete in sequence" << endl;
cout << "Press 6 for Delete anywhere" << endl;
cout << "Press 7 for Quit" << endl;
cin >> ch;
switch (ch) {
case 1:
cout << "Enter value for add: ";
cin >> val;
list.add(val);
break;
case 2:
cout << "Enter location to retrieve value: ";
cin >> loc;
val = list.retrieve(loc);
if (val != -1) {
cout << "Value at location " << loc << ": " << val <<
endl;
}
break;
case 3:
cout << "Enter value to add: ";
cin >> val;
cout << "Enter location to insert value: ";
cin >> loc;
list.InsertAnyWhere(val, loc);
break;
case 4:
list.display();
break;
case 5:
list.deleteVal();
break;
case 6:
cout << "Enter location to delete value: ";
cin >> loc;
list.deleteAnyWhere(loc);
break;
case 7:
exit(0);
break;
default:
cout << "Invalid choice" << endl;
}
} while (1);
return 0;
}
Create a list of atleast 10 students. Program should save the following information for each
student: Name, Reg. No., CGPA and Semester. Now perform the following tasks:
a) Display only those students whose CGPA is greater than 3.0
b) Display the students of 3 rd and 4 th semester
c) Display the students alphabetically
#include <iostream>
#include <vector>
#include <algorithm>
struct Student {
string name;
string regNo;
float cgpa;
int semester;
}
}
int main() {
vector<Student> students = {
{"Alice Smith", "CS101", 3.5, 2},
{"Bob Johnson", "CS102", 2.9, 3},
{"Charlie Brown", "CS103", 3.8, 4},
{"David Wilson", "CS104", 3.2, 3},
displayHighCGPA(students);
cout << endl;
displaySemesters(students);
cout << endl;
displayAlphabetically(students);
return 0;
}
Write a program containing two stacks of static arrays of size 5 each, elements of the array
should be of integer (int) type. The user will push values in the first stack, when a value is
popped from the first stack it should be pushed to the second stack. For each stack, you have to
check stack overflow and underflow conditions. User may remove an element from the second
stack as well.
#include <iostream>
using namespace std;
#define STACK_SIZE 5
class Stack {
private:
int arr[STACK_SIZE];
int top;
public:
Stack() : top(-1) {} // Initialize the stack with top as -1
int main() {
Stack stack1, stack2; // Two stacks of size 5 each
int choice, value;
while (true) {
cout << "\nMenu:\n"
<< "1. Push to Stack 1\n"
<< "2. Pop from Stack 1 and Push to Stack 2\n"
<< "3. Pop from Stack 2\n"
<< "4. Display Stack 1\n"
<< "5. Display Stack 2\n"
<< "6. Exit\n"
<< "Enter your choice: ";
cin >> choice;
switch (choice) {
case 1:
cout << "Enter value to push onto Stack 1: ";
cin >> value;
stack1.push(value);
break;
case 2:
value = stack1.pop();
if (value != -1) { // Only push to Stack 2 if pop was successful
stack2.push(value);
}
break;
case 3:
stack2.pop();
break;
case 4:
cout << "Stack 1: ";
stack1.display();
break;
case 5:
cout << "Stack 2: ";
stack2.display();
break;
case 6:
cout << "Exiting program." << endl;
return 0;
default:
cout << "Invalid choice. Please try again." << endl;
}
}
}
Write a program which should implement a stack using a dynamic array, whose size will
provided by user at program execution time. Elements of array used for stack are objects of
“student” class. “student” class contains attributes (privately defined) reg_no(int), st_name
(string) and cgpa (float). “student” class should also contain member functions (publicly
defined); constructor, input and output functions. User will push objects of class “student”,
values of attributes of objects will be provided by user. When an object will be popped from
stack, value of its attributes should be displayed on screen.
#include <iostream>
#include <string>
using namespace std;
// Define the 'student' class
class Student {
private:
int reg_no;
string st_name;
float cgpa;
public:
// Constructor to initialize attributes
Student() : reg_no(0), st_name(""), cgpa(0.0) {}
public:
// Constructor to initialize stack with given size
Stack(int size) : maxSize(size), top(-1) {
arr = new Student[maxSize];
}
int choice;
while (true) {
cout << "\nMenu:\n"
<< "1. Push Student\n"
<< "2. Pop Student\n"
<< "3. Display Stack\n"
<< "4. Exit\n"
<< "Enter your choice: ";
cin >> choice;
switch (choice) {
case 1: {
Student student;
cout << "Enter details for the student:\n";
student.input();
studentStack.push(student);
break;
}
case 2:
studentStack.pop();
break;
case 3:
studentStack.display();
break;
case 4:
cout << "Exiting program.\n";
return 0;
default:
cout << "Invalid choice. Please try again.\n";
}
}
}
Write a program to implement an airport runway simulation. The airport has only one runway
so scheduling has to be done for the arrival and departure of planes on the runway. At one
time, only one plane can arrive or leave the airport. Scheduling has to be done on the basis of
first come, first serve. Whichever flight comes first at the airport will be given the space on the
runway. Similarly, whichever flight requests for departure first, will be given the space on the
runway.
[Hint: Arrival of plane=enqueue, Departure of plane=dequeue]
#include <iostream>
using namespace std;
class SimpleQueue {
int front, rear, capacity;
int* queue;
public:
SimpleQueue(int size) {
capacity = size;
queue = new int[capacity];
front = rear = -1;
}
cout << "Flight " << flightNumber << " added to the queue\n";
}
}
int dequeue() {
if (front == -1 || front > rear) {
cout << "Queue is Empty\n";
return -1;
} else {
int flightNumber = queue[front];
front++;
return flightNumber;
}
}
bool isEmpty() {
return (front == -1 || front > rear);
}
};
int main() {
int runwayCapacity = 5;
SimpleQueue arrivalQueue(runwayCapacity);
SimpleQueue departureQueue(runwayCapacity);
while (true) {
switch (choice) {
case 1:
cout << "Enter flight number to add to arrival queue: ";
cin >> flightNumber;
arrivalQueue.enqueue(flightNumber);
break;
case 2:
cout << "Enter flight number to add to departure queue: ";
cin >> flightNumber;
departureQueue.enqueue(flightNumber);
break;
case 3:
if (!arrivalQueue.isEmpty()) {
flightNumber = arrivalQueue.dequeue();
if (flightNumber != -1) {
cout << "Flight " << flightNumber << " is arriving on the runway.\
n";
}
} else if (!departureQueue.isEmpty()) {
flightNumber = departureQueue.dequeue();
if (flightNumber != -1) {
cout << "Flight " << flightNumber << " is departing from the runway.\
n";
}
} else {
case 4:
cout << "Exiting...\n";
return 0;
default:
cout << "Invalid choice. Please try again.\n";
}
}
return 0;
}
Write a program which should implement a circular queue using static array of size 10 (10
elements array), elements of array should be of integer (int) type. User will input values to be
inserted at rear of circular queue (enqueue) and also number of elements to be removed from
front of circular queue (dequeue). Your program should display the value of elements which are
being removed from circular queue. Program should also calculate and display the average of
elements which have been removed from circular queue.
#include <iostream>
using namespace std;
class CircularQueue {
int front, rear, size, count;
int queue[10];
int removedSum;
int removedCount;
public:
CircularQueue() {
front = -1;
rear = -1;
size = 10;
count = 0;
removedSum = 0;
removedCount = 0;
}
if (front == rear) {
front = rear = -1;
} else {
front = (front + 1) % size;
}
count--;
}
if (removedCount > 0) {
double average = static_cast<double>(removedSum) / removedCount;
cout << "Average of removed elements: " << average << endl;
}
}
};
int main() {
CircularQueue cq;
int choice, value, numDequeue;
while (true) {
cout << "\n1. Enqueue value\n";
cout << "2. Dequeue values\n";
cout << "3. Exit\n";
cout << "Enter your choice: ";
cin >> choice;
switch (choice) {
case 1:
cout << "Enter value to enqueue: ";
cin >> value;
cq.enqueue(value);
break;
case 2:
cout << "Enter number of elements to dequeue: ";
cin >> numDequeue;
cq.dequeue(numDequeue);
break;
case 3:
cout << "Exiting...\n";
return 0;
default:
cout << "Invalid choice. Try again.\n";
}
}
return 0;
}
Insert front
void insertFront(Node*& head, int newData) {
Node* newNode = new Node();
newNode->data = newData;
newNode->next = head;
head = newNode;
}
Insert End
temp->next = newNode;
if (temp != nullptr) {
Node* newNode = new Node();
newNode->data = newData;
newNode->next = temp->next;
temp->next = newNode;
} else {
cout << "Node with value " << target << " not found." <<
endl;
}
}
Delete front
void deleteFront(Node*& head) {
if (head == nullptr) {
cout << "List is already empty." << endl;
return;
}
Delete End
if (head->next == nullptr) {
delete head;
head = nullptr;
return;
}
delete temp->next;
temp->next = nullptr;
}
if (head->data == target) {
Node* temp = head;
head = head->next;
delete temp;
return;
}
Node* temp = head;
while (temp->next != nullptr && temp->next->data != target) {
temp = temp->next;
}
if (temp->next != nullptr) {
Node* nodeToDelete = temp->next;
temp->next = temp->next->next;
delete nodeToDelete; /
} else {
cout << "Node with value " << target << " not found." <<
endl;
}
}
if (temp == nullptr) {
cout << "List is empty." << endl;
return;
}
Limit user so that he/she can only add 10 numbers in the list. After that give error that list
is full.
if (head == nullptr) {
head = newNode;
} else {
Node* temp = head;
while (temp->next != nullptr) {
temp = temp->next;
}
temp->next = newNode;
}
nodeCount++;
}
Stack code
#include<iostream>
using namespace std;
class MyStack
{
private:
int *stack;
int size;
int top;
public:
MyStack()
{
cout<<"Enter size of Stck"<<endl;
cin>>size;
stack=new int[size];
top=0;
}
bool IsFull()
{
if(top==size)
return true;
else
return false;
}
bool IsEmpty()
{
if(top==0)
return true;
else
return false;
}
void push(int val)
{
if(IsFull()==0)
{
stack[top]=val;
top++;
}
else
cout<<"Stack OverFlow"<<endl;
}
void POP()
{
if(IsEmpty()==0)
{
cout<<stack[top-1]<<" Is POPED"<<endl;
top--;
}
else
{
cout<<"Stack UnderFlow"<<endl;
}
}
};
void main()
{
int rerun;
int choice;
int val;
MyStack S1;
do{
cout<<"Press 1 to PUSH"<<endl;
cout<<"Press 2 to POP"<<endl;
cin>>choice;
if(choice==1)
{
cout<<"Enter value to push"<<endl;
cin>>val;
S1.push(val);
}
else if(choice==2)
{
S1.POP();
}
else
{
cout<<"Invalid choice"<<endl;
}
cout<<"Press 1 to rerun"<<endl;
cin>>rerun;
}while(rerun==1);
}
Ass1
#include <iostream>
#include <string>
class Student {
private:
int id;
string name;
string phoneNo;
public:
id = studentId;
name = studentName;
phoneNo = studentPhoneNo;
int getId() {
return id;
string getName() {
return name;
string getPhoneNo() {
return phoneNo;
void inputData() {
cout << "Enter student ID: ";
cin.ignore();
getline(cin, name);
getline(cin, phoneNo);
void outputData() {
cout << "Student Phone Number: " << phoneNo << endl;
};
int main() {
Student student1;
student1.inputData();
student1.outputData();
return 0;