Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
642 B
4
Indexable
#include <iostream>
using namespace std;

class employees {
public:
  int age;
  string name;

  employees() {
    age = 0;
    name = "";
  }
};

int main() {
  employees emp[5];
  cout << "Enter details of 5 Employees: " << endl;
  employees t;
  t.name = "";
  t.age = 0;

  for (int i = 0; i < 5; i++) {
    cout << "\nEnter Name and Age of " << i + 1 << " Employee: " << endl;
    cin >> t.name >> t.age;
    emp[i] = t;
  }

  cout << "\nThe details are as follows: " << endl;
  for (int i = 0; i < 5; i++) {
    cout << "The Name and Age of " << i + 1 << " Employee is: " << emp[i].name << " " << emp[i].age << endl;
  }
  return 0;
}