In: Computer Science
Question 2
employment_id, int; salary, float; marriage_status, bool.
#include<bits/stdc++.h>
#include<climits>
using namespace std;
struct Employee
{
        int employment_id;
        float salary;
        bool marriage_status;
        void printAttribute(int i) {
                cout << i << " " << "Emp id " << employment_id << " Salary " << salary << " marriage_status  " << marriage_status << endl;
        }
};
// Driver program to test above functions
void PrintArrayElement(struct Employee y[]) {
        double ans = 0;
        for (int i = 0; i < 4; i++) {
                ans += y[i].salary;
                y->printAttribute(i);
        }
        cout << "The sum of salary of each of the attribute is " << ans << "\n";
}
int main()
{
        struct Employee e = {1234, 34000.00, true}; //initialising the struct
        struct Employee y[4];
        for (int i = 0; i < 4; i++) {
                y[i].employment_id = i + 1;
                y[i].marriage_status = 1;
                y[i].salary = 34000.00;
        }
        PrintArrayElement(y);
        // rest of the code
}
Example run

if you like the answer, please consider upvoting. ;-)