Thursday 8 December 2016

Write a program that declares a structure to store the code number, salary and grade of an employee....


Write a program that declares a structure to store the code number, salary and grade of an employee. the program defines two structure variables, inputs records of two employees and the displays the record of the employee with more salary.


        #include <iostream.h>
        #include <conio.h>
         struct employee
        {
            int code_num;
            int salary;
            int grade;
        };

        int main()
        {
            employee e1, e2;
             cout<<" Enter the code number, salary and grade of the first employee:";
             cin>>e1.code_num>>e1.salary>>e1.grade;
             cout<<"Enter the code number, salary and grade of the second employee:";
             cin>>e2.code_num>>e2.salary>>e2.grade;
             cout<<" The Employee with more salary is: "<<endl;

             if (e1.salary > e2.salary)
            {
                   cout<<" Code Number "<<e1.code_num<<endl;
                   cout<<" Salary "<<e1.salary<<endl;
                   cout<< " Grade "<<e1.grade;
            }
            else
            {
                   cout<< " Code Number "<<e2.code_num<<endl;
                   cout<<" Salary "<<e2.salary<<endl;
                   cout<<" Grade "<<e2.grade;
            }
            return 0;
       

Output:


No comments:

Post a Comment

If you have any doubt please let me know

Methods in JAVA Language

 In general, a way may be thanks to perform some task. Similarly, the tactic in Java may be a collection of instructions that performs a sel...