#include <iostream>
#include <string>
using namespace std;
class Person{
public:
string name;
int salary;
int id;
};
Person* employees[10];
int empCount = 0;
void addEmployee();
void showEmployees();
Person* findEmployee(int id);
void sortEmployees();
int main()
{
addEmployee();
addEmployee();
addEmployee();
addEmployee();
addEmployee();
addEmployee();
addEmployee();
addEmployee();
addEmployee();
addEmployee();
addEmployee();
addEmployee();
addEmployee();
sortEmployees();
showEmployees();
cout << findEmployee(2)->name << endl;
return 0;
}
void addEmployee(){
if(empCount < 10){
Person* p = new Person;
cout << "Enter your name: ";
c
fix invalid codeFri, 31 Mar 2023 def add(a, b):
return a + b
#include <iostream>
#include <conio.h>
using namespace std;
struct employee {
string name;
int id;
double salary;
};
int main()
{
employee employees[10];
void display(employee[]);
void enter(employee[]);
void displayEmployee(employee[]);
void search(employee[]);
void sort(employee[]);
int option;
enter(employees);
do {
cout << "\n\n\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWelcome to the Employees System\n\n\n\n";
cout << "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t1 - Enter the Employees Data\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t
#include<iostream>
#include<cstring>
using namespace std;
//structure to store employee data
struct Employee
{
int id;
char name[50];
int age;
long salary;
};
//function to get employee data from user
Employee getEmployee()
{
Employee emp;
cout<<"Enter Employee id: ";
cin>>emp.id;
cout<<"Enter Employee Name: ";
cin.ignore();
cin.getline(emp.name, 50);
cout<<"Enter Employee Age: ";
cin>>emp.age;
cout<<"Enter Employee Salary: ";
cin>>emp.salary;
cout<<endl;
return emp;
}
//function to print employee data
void printEmployee(Employee emp)
{
cout<<"Id: "<<emp.id<<endl;
cout<<"Name: "<<emp.name<<endl;
cout<<"
#include <iostream>
using namespace std;
struct employee
{
int id;
int salery;
string name;
};
employee emp[10];
int count = 0;
void insertEmp()
{
if (count <= 10)
{
cout << "Enter id: ";
cin >> emp[count].id;
cout << "Enter salery: ";
cin >> emp[count].salery;
cout << "Enter name: ";
cin >> emp[count].name;
cout << "-------->" << endl;
count++;
}
else
{
cout << "The system is full!" << endl;
}
}
void printEmp()
{
for (int i = 0; i < count; i++)
{
cout << "id: " << emp[i].id << endl;
cout << "salery: " << emp[i].salery << endl
#include <iostream>
#include <string>
using namespace std;
const int size = 10;
struct employee {
int id;
string name;
float salary;
};
int main() {
int choice;
employee emp[size] = {};
cout << "Enter employee data:\n";
for (int i = 0; i < size; i++) {
cout << "ID: ";
cin >> emp[i].id;
cout << "Name: ";
cin >> emp[i].name;
cout << "Salary: ";
cin >> emp[i].salary;
}
do
{
cout << "1) Show employees\n";
cout << "2) Search employee\n";
cout << "3) Sort employees\n";
cout << "4) End\n";
cin >> choice;
switch (choice)
{
case 1:
for (int i = 0;
#include <iostream>
using namespace std;
const int MAX = 10;
struct Employee{
int id;
double salary;
};
void displayEmployees(Employee employees[], int size);
void addEmployee(Employee employees[]);
void sortEmployees(Employee employees[], int size);
int main() {
Employee employees[MAX];
int userChoice = 0;
while (userChoice != 5) {
cout << "1- Add New Employee" << endl;
cout << "2- Display Employees" << endl;
cout << "3- Sort Employees" << endl;
cout << "4- Search Employee" << endl;
cout << "5- Exit " << endl;
cout << "Enter your choice: ";
cin >> userChoice;
if (userChoice == 1) {
addEmployee(employees);
}
else if (userChoice == 2) {
displayEmployees(employees, MAX);
}
else if (userChoice == 3) {
sortEmployees(employees
int search_in_file(char *fname, char *str)
{
FILE *fp;
int line_num = 1;
int find_result = 0;
char temp[512];
if((fp = fopen(fname, "r")) == NULL) {
return(-1);
}
while(fgets(temp, 512, fp) != NULL) {
if((strstr(temp, str)) != NULL) {
printf("A match found on line: %d\n", line_num);
printf("\n%s\n", temp);
find_result++;
}
line_num++;
}
if(find_result == 0) {
printf("\nSorry, couldn't find a match.\n");
}
//Close the file if still open.
if(fp) {
fclose(fp);
}
return(0);
}
``
fix invalid codeFri, 31 Mar 2023 <a name="external-links"></a>
### External Links
- [Markdown Cheatsheet](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet)
struct employee{
int id;
string name;
int salary;
}
#include <iostream>
#include <string>
using namespace std;
struct employee{
int id;
string name;
int salary;
};
void insert(employee& e){
cout<<"Enter the id:"<<endl;
cin>>e.id;
cout<<"Enter the name:"<<endl;
cin>>e.name;
cout<<"Enter the salary:"<<endl;
cin>>e.salary;
}
void print(employee& e){
cout<<"id: "<<e.id<<endl;
cout<<"name: "<<e.name<<endl;
cout<<"salary: "<<e.salary<<endl;
}
void search(employee* list, int size){
int x;
cout<<"Enter the id of the emplyee:"<<endl;
cin>>x;
int found = 0;
for(int i=0; i<size; i++){
struct student
{
int id;
string name;
float salary;
};
vector<student> students;
struct student{
char name[50];
int id;
float salary;
};
int main(){
struct student s[100];
int n,i,id1;
printf("enter number of students\n");
scanf("%d",&n);
for (i=0;i<n;i++){
printf("enter name of student\n");
scanf("%s",&s[i].name);
printf("enter id of student\n");
scanf("%d",&s[i].id);
printf("enter salary of student\n");
scanf("%f",&s[i].salary);
}
for (i=0;i<n;i++){
printf("\nstudent name : %s\n",s[i].name);
printf("student id : %d\n",s[i].id);
printf("student salary : %.2f\n",s[i].salary);
#include "stdafx.h"
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
struct Employee
{
int id;
string name;
float salary;
};
void printEmployee(Employee employee)
{
cout << employee.id << " : " << employee.name << " - " << employee.salary << endl;
}
struct Record
{
Record(vector<Employee> employees, vector<int> deletedIds)
{
this->employees = employees;
this->deletedIds = deletedIds;
}
vector<Employee> employees;
vector<int> deletedIds;
void add(Employee employee)
{
if (deletedIds.empty())
{
employee.id = employees.size() + 1;
}
else
{
employee.id =
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
using namespace std;
struct emp {
int id;
string name;
int salary;
};
void addToList(vector<emp>& list) {
emp e;
cout << "id: ";
cin >> e.id;
cout << "name: ";
cin >> e.name;
cout << "salary: ";
cin >> e.salary;
list.push_back(e);
}
void printList(const vector<emp>& list) {
for (const emp& e : list) {
cout << e.id << " " << e.name << " " << e.salary << endl;
}
}
void searchInList(const vector<emp>& list) {
int id;
cout << "enter id to search for: ";
cin >> id;
for
#include <iostream>
#include <string>
using namespace std;
struct employee{
string name;
int salary;
int id;
};
void menu(){
cout << "1- Enter Employees" << endl;
cout << "2- Print Employees" << endl;
cout << "3- Search By ID" << endl;
cout << "4- Search By Salary" << endl;
cout << "5- Search By Name" << endl;
cout << "6- Quit" << endl;
}
void EnterEmployee(employee employeeList[], int i){
cout << "Name: ";
cin >> employeeList[i].name;
cout << "Salary: ";
cin >> employeeList[i].salary;
cout << "ID: ";
cin >> employeeList[i].id;
}
void printEmployees(employee EmployeeList[], int i){
cout << "Name: " << EmployeeList[i].name
def addemployee(name, salary, id)
employees[id] = (name, salary)
def printemployee(id)
if id in employees:
print(employees[id][0], employees[id][1])
else
print("no such id")
def search(name):
for (key, value) in employees.items():
if value[0] == name:
print(key)
print("not found")
def sort_salary():
sorted_employees = sorted(employees.items(), key=lambda x: x[1][1])
#include <iostream>
using namespace std;
struct employee{
string name;
int id;
double salary;
};
int main() {
employee emp[10];
for (int i = 0; i < 10; i++) {
cout << "Enter the name of employee " << i+1 << ": ";
cin >> emp[i].name;
cout << "Enter the id of employee " << i+1 << ": ";
cin >> emp[i].id;
cout << "Enter the salary of employee " << i+1 << ": ";
cin >> emp[i].salary;
cout << endl;
}
cout << "---------------------------" << endl;
for (int i = 0; i < 10; i++) {
cout << "The name of employee " << i+1 << " is: " << emp[i].name << endl;
cout << "The id of employee " << i+
struct Student {
string name;
int age;
string department;
double gpa;
}
Student find_student(Student students[], string name) {
for (Student student : students) {
if (student.name == name) {
return student;
}
}
return null;
}
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
struct Employee {
int emp_id;
std::string name;
int salary;
};
std::vector<Employee> employees;
void insert_employee(Employee &temp);
void print_employees();
void find_employee();
void sort_employees();
int main()
{
int choice;
bool exit = false;
do
{
std::cout << "Menu:\n"
<< "1: Insert employee\n"
<< "2: Print employees\n"
<< "3: Find employee\n"
<< "4: Sort employees\n"
<< "5: Exit\n"
<< "Choice: ";
std::cin >> choice;
switch (choice)
{
case 1:
{
Employee temp;
insert_employee(temp);
break;
}
case 2:
#include <iostream>
#include <iomanip>
using namespace std;
struct Employee{
int id;
float salary;
};
void enterData(Employee *employees, int size);
void printData(Employee *employees, int size);
void searchEmployee(Employee *employees, int size);
void largestSalary(Employee *employees, int size);
void sortEmployees(Employee *employees, int size);
int main()
{
int size = 10;
Employee employees[size];
enterData(employees, size);
printData(employees, size);
searchEmployee(employees, size);
largestSalary(employees, size);
sortEmployees(employees, size);
printData(employees, size);
return 0;
}
void enterData(Employee *employees, int size)
{
for (int i = 0; i < size; i++) {
cout << "Enter the employee number "
struct employee{
char name[20];
int salary;
};
employee employees[10];
void input() {
for (int i = 0; i < 10; i++) {
cout << "please enter the name of the employee: ";
cin.getline(employees[i].name, 20);
cout << "please enter the salary of the employee: ";
cin >> employees[i].salary;
cin.ignore();
}
}
void print() {
for (int i = 0; i < 10; i++) {
cout << employees[i].name << " " << employees[i].salary << endl;
}
}
void search() {
cout << "enter the name of the employee: ";
char name[20];
cin.getline(name, 20);
for (int i = 0; i < 10; i++) {
if (strcmp(employees[i].name, name) == 0) {
cout << employees
#include <iostream>
using namespace std;
struct Employee
{
int number;
float sal;
};
void print_records(Employee employee[], int size);
void print_all(Employee employee[], int size);
void print_highest_sal(Employee employee[], int size);
void sort_by_sal(Employee employee[], int size);
int main()
{
int num_of_emp;
cout << "Enter Number of Employees: ";
cin >> num_of_emp;
Employee emp[num_of_emp];
for (int i = 0; i < num_of_emp; i++)
{
cout << "Enter Employee Number " << i + 1 << ": ";
cin >> emp[i].number;
cout << "Enter Employee Salary " << i + 1 << ": ";
cin >> emp[i].sal;
cout << endl;
}
cout << "1- To print All
#include <iostream>
#include <string>
using namespace std;
struct student{
string name;
int age;
int salary;
};
struct student students[1000];
int currentIndex = 0;
void addStudent(string name, int age, int salary){
students[currentIndex].name = name;
students[currentIndex].age = age;
students[currentIndex].salary = salary;
currentIndex++;
}
void printStudent(struct student x){
cout << "Student name is: " << x.name << endl;
cout << "Student age is: " << x.age << endl;
cout << "Student salary is: " << x.salary << endl;
cout << "-----------------------------" << endl;
}
void searchStudent(string name){
struct student x;
bool found = false;
for (int i = 0; i < currentIndex; i++){
if (students[i].name == name){
x = students[
#include <iostream>
#include <iomanip>
#include <string>
int main() {
// student 1
std::string name1;
char grade1;
int age1;
// student 2
std::string name2;
char grade2;
int age2;
// student 3
std::string name3;
char grade3;
int age3;
// student 4
std::string name4;
char grade4;
int age4;
// student 1
std::cout << "Enter the first student's name: ";
std::getline(std::cin, name1); // get the whole line
std::cout << "Enter the first student's grade: ";
std::cin >> grade1;
std::cout << "Enter the first student's age: ";
std::cin >> age1;
std::cin.ignore(32767, '\n'); // skip to the next newline
// student
#include <iostream>
#include <string>
using namespace std;
struct Employee{
int id;
string name;
float salary;
};
void addEmployee(Employee arr[], int size);
void printEmployee(Employee arr[], int size);
void searchByName(Employee arr[], int size);
void searchMaxSalary(Employee arr[], int size);
// C++ program to implement basic stack
// operations
#include <bits/stdc++.h>
using namespace std;
#define MAX 1000
class Stack {
int top;
public:
int a[MAX]; // Maximum size of Stack
Stack() { top = -1; }
bool push(int x);
int pop();
int peek();
bool isEmpty();
};
bool Stack::push(int x)
{
if (top >= (MAX - 1)) {
cout << "Stack Overflow";
return false;
}
else {
a[++top] = x;
cout << x << " pushed into stack\n";
return true;
}
}
int Stack::pop()
{
if (top < 0) {
cout << "Stack Underflow";
return 0;
fix invalid codeFri, 31 Mar 2023 #include <iostream>
using namespace std;
const int MAX = 10;
struct Employee{
int id;
double salary;
};
void displayEmployees(Employee employees[], int size);
void addEmployee(Employee employees[]);
void sortEmployees(Employee employees[], int size);
int main() {
Employee employees[MAX];
int userChoice = 0;
while (userChoice != 5) {
cout << "1- Add New Employee" << endl;
cout << "2- Display Employees" << endl;
cout << "3- Sort Employees" << endl;
cout << "4- Search Employee" << endl;
cout << "5- Exit " << endl;
cout << "Enter your choice: ";
cin >> userChoice;
if (userChoice == 1) {
addEmployee(employees);
}
else if (userChoice == 2) {
displayEmployees(employees, MAX);
}
else if (userChoice == 3) {
sortEmployees(employ
#include <iostream>
using namespace std;
struct emp
{
int id;
string name;
int salary;
string post;
int day;
string month;
int year;
};
emp e[20];
int x;
void enter()
{
cout<<"Enter the number of employees: ";
cin>>x;
for(int i=0; i<x; i++)
{
cout<<"Enter id of employee "<<i+1<<": ";
cin>>e[i].id;
cout<<"Enter name of employee "<<i+1<<": ";
cin>>e[i].name;
cout<<"Enter salary of employee "<<i+1<<": ";
cin>>e[i].salary;
cout<<"Enter post of employee "<<i+1<<": ";
cin>>e[i].post;
cout<<"Enter day of birth of employee "
#include <iostream>
#include <string>
using namespace std;
struct Person {
string name;
int id;
int salary;
};
int main() {
int count;
cout << "Enter number of people\n";
cin >> count;
Person people[count];
for (int i=0; i < count; i++) {
cout << "Enter id, name, salary\n";
cin >> people[i].id >> people[i].name >> people[i].salary;
}
for (int i=0; i < count; i++) {
cout << people[i].id << " " << people[i].name << " " << people[i].salary << "\n";
}
}
fix invalid codeFri, 31 Mar 2023
#include <iostream>
using namespace std;
class Employee
{
private:
int ID;
float salary;
string name;
public:
void recieve_data()
{
cout << "Enter Name and Salary" << endl;
cin >> name >> salary;
}
void display_data()
{
cout << "Name = " << name << endl << "Salary = " << salary << endl;
}
void search_employee(float salary)
{
if(this->salary == salary)
{
cout << "Name = " << name << endl << "Salary = " << salary << endl;
}
}
};
int main()
{
Employee employee[10];
for(int i = 0; i < 10; i++)
{
employee[i].recieve_data();
}
for(int i = 0; i < 10; i++)
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
string arr[10];
int arr2[10];
//int arr3[10];
int i = 0;
int j = 0;
int k = 0;
int l = 0;
int s = 0;
int m = 0;
int o = 0;
int p = 0;
int main()
{
int a;
cout << "Enter 1 for entering data \n";
cout << "Enter 2 for print data \n";
cout << "Enter 3 for Search \n";
cout << "Enter 4 for find the largest value \n";
cout << "Enter 5 for sorting\n";
cin >> a;
if (a == 1) {
int b;
cout << " Enter 1 for enter data \n Enter 2 for exit data enter \n";
cin >> b;
if (b == 1) {
string name;