I am having some errors and Im still beginner level. please fix this code for me, thanks

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.


#include<iostream>
#include<conio.h>
#include<iomanip>

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');

system("pause");
}
Last edited on
Hi smackthat1!
It had very paltry mistakes, now I have corrected them. If you have got any problems regarding this feel free to ask me.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#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
Last edited on
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 :)..!!
I came to know about this site today only. I also want some help so I posted it in the forums, take a look if you know the answer. :D
http://www.cplusplus.com/forum/general/174405/
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 :)..!!
Oh! that will be so nice of you:)
Youre welcome pal, have a nice time :)
thanks=)
Topic archived. No new replies allowed.