Write a c++ program segment to assign data to members of a structure called employee having name ,age and salary then display it.
int main() {
//declare a variable of type Employee as
EMPLOYEE emp;
//propmt the user to enter the employee details
//i.e name, age, salary and store them in corresponding
// fields of structure variable
cout << "Enter name of employee : ";
cin.getline(emp.employee_name, 50);
cout << "Enter employee age : ";
cin >> emp.employee_age;
cout << "Enter salary of employee : ";
cin >> emp.employee_salary;
// Printing employee details
cout << "\n*** Employee Details ***" << endl;
cout << "Employee Name : " << emp.employee_name << endl;
cout << "Employee age : " << emp.employee_age<<endl;
cout<< "Employee Salary : " << emp.employee_salary << endl;
return 0;
}
Comments
Leave a comment