Friday 11 August 2017

Create a structure called employee that contains two members: an employee number (type int) and the employee’s compensation (in dollars; type float). Ask the user to fill in this data for three employees, store it in three variables of type struct employee, and then display the information for each employee.



Create a structure called employee that contains two members: an employee number (type int) and the employee’s compensation (in dollars; type float). Ask the user to fill in this data for three employees, store it in three variables of type struct employee, and then display the information for each employee.
SOLUTION:
#include<iostream.h>
#include<conio.h>
///////////////////////////////////////////////////////////// Define Structures ////////////////////////////////////////////////////////////
struct employee
            {
            int number;
            float compen;
            };
///////////////////////////////////////////////////// Define Structure Variables /////////////////////////////////////////////////////
employee E1,E2,E3;
void main()
{
clrscr();
///////////////////////////////////////////////////////////////// Take Input ////////////////////////////////////////////////////////////////////
cout<<"Enter Number and Compensation of 1st Employee ";
                        cin>>E1.number>>E1.compen;
cout<<"Enter Number and Compensation of 2nd Employee ";
                        cin>>E2.number>>E2.compen;
cout<<"Enter Number and Compensation of 3rd Employee ";
                        cin>>E3.number>>E3.compen;
////////////////////////////////////////////////////////////////////// Output /////////////////////////////////////////////////////////////////////
cout<<"\nNumber\t\tCompensation\n\n";
cout<<E1.number<<"\t\t$  "<<E1.compen<<"\n";
cout<<E2.number<<"\t\t$  "<<E2.compen<<"\n";
cout<<E3.number<<"\t\t$  "<<E3.compen<<"\n";
getch();
}
OUTPUT:


0 comments: