Create a structure called employee that contains two members: an employee ID (type int) and the employee’s compensation (in Euros; 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.
struct employee
{
int number;
float compensation;
};
main void ();
{ cout<<"-------------------------------------------------------------------------------\n"<<endl;
employee e[3]; int i;
do{
for(i=0; i<3; i++)
{
cout<<"Enter the number of employee number "<<i+1<<" : "; cin>>e[i].number;
cout<<"Enter the compensation of employee number "<<i+1<<" : "; cin>>e[i].compensation;}
cout<<"Employee number"<<" Employee compensation\n";
for(i=0; i<3; i++) cout<<setw(15)<<e[i].number<<setw(24)<<e[i].compensation<<endl;
cout<<"\n\n !Press c to continue or any key to exit."<<endl<<endl;
}while(getch()=='c');
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
struct employee
{
int number;
float compensation;
};
void main()
//It should be void main() and you must not put semi colon after main() function.
{
cout<<"------------------------------------------------------------------------\n"<<endl;
//better use clrscr(); at start to clear the screen.
employee e[3]; int i;
do{
for(i=0; i<3; i++)
{
cout<<"Enter the ID of employee number "<<i+1<<" : "; cin>>e[i].number;
//better use the words mentioned in the question, from exam point of view.
cout<<"Enter the compensation of employee number "<<i+1<<" : "; cin>>e[i].compensation;}
cout<<"\nEmployee ID \t Employee Compensation\n";
///t leaves one tab space( these are known as 'escape sequences').
for(i=0; i<3; i++) cout<<setw(6)<<e[i].number<<setw(21)<<e[i].compensation<<endl;
cout<<"\n\nPress c to continue or any key to exit."<<endl<<endl;
}while(getch()=='c');
getch(); //I have Turbo C++( Version 3.0), on using system("pause"); it gives error.
}
P.S. Make sure you remove the comments which I have given in the program. :D
Yeah,thank you VIbgyor, Im really touched by the help i am receiving from this forum. I almost thought of giving up c++, this forum has motivated me and thanks to very nice people like you, who are supporting me :), Thanks a lot :)..!!
Not Im not that pro in c++ at the moment Im really sorry, but i can ask some my friends and see how it goes :).. hope you find the solution before the deadline :)..!!