0% found this document useful (0 votes)
2 views

Oop Assignment (1)

The document contains C++ code for managing employee sales data. It defines a structure for employees, collects their details and sales data, sorts the sales data by quarter using selection sort, and then displays the sorted sales data. There are several syntax errors in the code that need to be corrected for it to compile and run successfully.

Uploaded by

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

Oop Assignment (1)

The document contains C++ code for managing employee sales data. It defines a structure for employees, collects their details and sales data, sorts the sales data by quarter using selection sort, and then displays the sorted sales data. There are several syntax errors in the code that need to be corrected for it to compile and run successfully.

Uploaded by

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

code

#include <iostream>

#include <string>

using namespace std;

struct Employee {

string name;

string id;

int sales[5][4];

};

void selectionSort(int arr[], int size) {

for (int I = 0; I < size – 1; i++) {

int minIndex = I;

for (int j = I + 1; j < size; j++) {

If (arr[j] < arr[minIndex]) {

minIndex = j;

int temp = arr[i];

arr[i] = arr[minIndex];

arr[minIndex] = temp;

}
int main() {

Employee employees[3];

for (int I = 0; I < 3; i++) {

cout << “Enter details for Employee “ << I + 1 << “:\n”;

cout << “Name: “;

cin >> employees[i].name;

cout << “ID: “;

cin >> employees[i].id;

cout << “Enter sales data for 5 years (4 quarters each):\n”;

for (int year = 0; year < 5; year++) {

for (int quarter = 0; quarter < 4; quarter++) {

cout << “Year “ << year + 1 << “, quarter “ << quarter + 1 << “: “;

Cin >> employees[i].sales[year][quarter];

for (int I = 0; I < 3; i++) {

for (int quarter = 0; quarter < 4; quarter++) {

Int quarterSales[5];

for (int year = 0; year < 5; year++) {

quarterSales[year] = employees[i].sales[year][quarter];

selectionSort(quarterSales, 5);

for (int year = 0; year < 5; year++) {

employees[i].sales[year][quarter] = quarterSales[year];
}

cout << “\nSorted Sales Data :\n”;

for (int I = 0; I < 3; i++) {

cout << “Employee: “ << employees[i].name << “ (ID: “ << employees[i].id << “)\n”;

for (int year = 0; year < 5; year++) {

cout << “Year “ << year + 1 << “: “;

for (int quarter = 0; quarter < 4; quarter++) {

cout << employees[i].sales[year][quarter] << “ “;

cout << endl;

cout << endl;

return 0;

Output

You might also like