YAKSHIC
YAKSHIC
YAKSHIC
#include <iostream>
class velocity2;
// class velocity1
class velocity1 {
private:
float v1;
public:
velocity1() {
v1 = 0;
velocity1(float v) {
v1 = v;
operator velocity2();
void show() {
cout << "velocity1: " << v1 << " km/h" << endl;
};
// class velocity2
class velocity2 {
private:
float v2;
public:
velocity2() {
v2 = 0;
velocity2(float v) {
v2 = v;
operator velocity1();
void display() {
cout << "velocity2: " << v2 << " m/s" << endl;
};
velocity1::operator velocity2() {
velocity2::operator velocity1() {
// main function
int main() {
velocity1 v1(60);
velocity2 v2;
v2=v1;
v1.show(); }
v2.display();
return 0;
Output:
velocity1: 60 km/h
#include<iostream>
class Bank {
public:
int AC_num;
float balance;
void operator++() {
balance += 1000;
Bank sum;
cout << sum.balance << " + " << amountToadd << " = " <<
sum.balance<<endl;
Bank diff;
cout << diff.balance << " - " << amountToDeduct << " = " <<
diff.balance<<endl;
cout <<endl<< other.name << " has a larger balance than " << name;
} else {
cout <<endl<< name << " has a larger balance than " << other.name;
void getDetails() {
cout << "Enter the name of the customer" << endl;
void show() {
};
int main() {
//Getting Details
ac1.getDetails();
ac2.getDetails();
//Performing Operations
++ac1;
ac1.show();
ac1.operator+(194.8);
ac1.operator-(150.8);
// Comparing balances
ac1.compare(ac2);
return 0;
Output:
Harry
Hogwarts
9048253
100
Hermoine
9534235
200
Name: Harry
Address: Hogwarts
Balance: 1100
Name: Yakshi Chauhan Course: BCA Section: H Univ. Roll num: 2103199
#include <iostream>
#define MAX 10
public:
int top;
T Data[MAX];
ARRAY ()
top = -1;
void insert ()
T ele;
if (top == MAX - 1)
return;
else
top++;
Data[top] = ele;
void display ()
{
if (top == -1)
else
int i;
// Function to Sort
void sort() {
if (top == -1) {
else {
T temp = Data[j];
Data[j + 1] = temp;
};
int main ()
int ch;
do
switch (ch)
case 1:
stk1.insert ();
break;
case 2:
stk1.display ();
break;
case 3:
stk1.sort ();
break;
return 0;
Output:
Array is empty
89
Enter the your choice
43
450
184 450 43 89
43 89 184 450
#include <iostream>
using namespace std;
class Base {
public:
virtual void display() {
cout << "Base class display()" << endl;
}
};
class Derived1 : public Base {
public:
void display() override {
cout << "Derived1 class display()" << endl;
}
};
class Derived2 : public Derived1 {
public:
void display() override {
cout << "Derived2 class display()" << endl;
}
};
int main() {
Base* basePtr;
Derived1 derived1Obj;
Derived2 derived2Obj;
basePtr = &derived1Obj;
basePtr->display();
basePtr = &derived2Obj;
basePtr->display();
return 0;
}
Output:
Derived1 class display()
Derived2 class display()
#include <iostream>
cout << "Argument " << i << ": " << argv[i] << endl;
return 0;
}
Output:
Number of arguments: 1
Arguments:
Argument 0:
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <limits>
class Employee {
private:
string empName;
string department;
string empId;
int age;
double salary;
public:
// Default constructor
Employee() {}
// Parameterized constructor
// Getter functions
return empName;
return department;
return empId;
return age;
return salary;
if (file.is_open()) {
file << empName << " " << department << " " << empId << " " <<
age << " " << salary << endl;
file.close();
else {
ifstream file(fileName);
if (file.is_open()) {
string line;
file.close();
else {
cout << "Error opening the file." << endl;
ifstream file(fileName);
if (file.is_open()) {
string line;
if (id == empId) {
found = true;
break;
file.close();
if (!found) {
cout << "Employee with ID " << empId << " not found." <<
endl;
}
}
else {
ifstream inputFile(fileName);
if (inputFile.is_open()) {
string line;
if (id != empId) {
lines.push_back(line);
else {
found = true;
inputFile.close();
ofstream outputFile(fileName);
if (outputFile.is_open()) {
outputFile.close();
if (found) {
cout << "Employee with ID " << empId << " deleted
successfully." << endl;
else {
cout << "Employee with ID " << empId << " not found." <<
endl;
else {
else {
}
// Function to edit an employee by employee ID
fstream file(fileName);
if (file.is_open()) {
string line;
if (id != empId) {
lines.push_back(line);
else {
found = true;
lines.push_back(line);
file.close();
ofstream outputFile(fileName);
if (outputFile.is_open()) {
outputFile.close();
if (found) {
cout << "Employee with ID " << empId << " edited
successfully." << endl;
else {
cout << "Employee with ID " << empId << " not found." <<
endl;
else {
else {
}
// Function to sort the employee records by employee name
ifstream file(fileName);
if (file.is_open()) {
string line;
lines.push_back(line);
file.close();
sort(lines.begin(), lines.end(),
);
ofstream outputFile(fileName);
if (outputFile.is_open()) {
outputFile.close();
cout << "Employee records sorted by employee name." << endl;
else {
else {
};
int main() {
int choice;
string empId;
while (true) {
switch (choice) {
case 1: {
int age;
double salary;
employee.insertEmployee(fileName);
break;
}
case 2: {
Employee::displayAllEmployees(fileName);
break;
case 3: {
Employee::searchEmployee(fileName, empId);
break;
case 4: {
Employee::deleteEmployee(fileName, empId);
break;
case 5: {
Employee::editEmployee(fileName, empId);
break;
}
case 6: {
Employee::sortEmployees(fileName);
break;
case 7: {
return 0;
default: {
break;
cin.get();
Output:
/tmp/ufzld80ys5.o
Menu:
1. Insert an employee
2. Display all employees
3. Search an employee
4. Delete an employee
5. Edit an employee
7. Exit
Enter age: 22
Menu:
1. Insert an employee
3. Search an employee
4. Delete an employee
5. Edit an employee
7. Exit
Enter age: 23
Menu:
1. Insert an employee
3. Search an employee
4. Delete an employee
5. Edit an employee
7. Exit
Enter age: 22
1. Insert an employee
3. Search an employee
4. Delete an employee
5. Edit an employee
7. Exit
Menu:
1. Insert an employee
3. Search an employee
4. Delete an employee
5. Edit an employee
7. Exit
Menu:
1. Insert an employee
3. Search an employee
4. Delete an employee
5. Edit an employee
7. Exit
Menu:
1. Insert an employee
3. Search an employee
4. Delete an employee
5. Edit an employee
7. Exit
#include <iostream>
#include <string>
size_t pos = 0;
sos += replacement.length();
cnt main() {
string str;
string substr;
string replacement;
getline(cin, substr);
getline(cin, replacement);
return 0;
Output:
#include<iostream>
int main(){
double n,d,division;
try{
if(d==0){
throw d;
division=n/d;
cout<<n<<"/"<<d<<"="<<division<<endl;
catch(int num_exception){
return 0;
Output:
30
--------------------------------