getting many errors in this new tcwin4.5

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sweetswati7
    New Member
    • Mar 2014
    • 1

    getting many errors in this new tcwin4.5

    please help me........
    it is making many errors i don't know what to do
    here's my program...
    please tell why it is not working
    Code:
    #include"iostream.h"
    #include"conio.h"
    #include"stdio.h"
    struct employee
    {
    	int empno;
    	char empname[40];
    	char empaddress[40];
    	float basic,da,hra,cca,pf,totalsalary;
    };
    void main()
    {
    	clrscr();
    	employee em[4];
    	for(int i=0;i<4;++i)
    	{
    	  cout<<"enter the number of employee "<<endl;
    	  cin>>em[i].empno;
    	  cout<<"enter the name of employee "<<endl;
    	  gets(em[i].empname);
    	  cout<<"enter the address of employee "<<endl;
    	  gets(em[i].empaddress);
    	  cout<<"enter the basic of employee "<<endl;
    	  cin>>em[i].basic;
    	  cout<<"enter the pf of employee "<<endl;
    	  em[i].pf=0.1*em[i].basic;
    	  cout<<"enter da of employee "<<endl;
    	  em[i].da=1.23*em[i].basic;
    	  cout<<"enter hra of an employee "<<endl;
    	  cin>>em[i].hra;
    	  cout<<"enter cca of an employee "<<endl;
    	  cin>>em[i].cca;
    	  em[i].totalsalary=em[i].basic+em[i].da+em[i].pf+em[i].cca+em[i].hra;
    	  cout<<"employee number is "<<em[i].empno<<endl;
    	  cout<<"employee name is "<<em[i].empname<<endl;
    	  cout<<"employee address is "<<em[i].empaddress<<endl;
    	  cout<<"basic salary is "<<em[i].basic<<endl;
    	  cout<<"pf is "<<em[i].pf<<endl;
    	  cout<<"da is "<<em[i].da<<endl;
    	  cout<<"hra is "<<em[i].hra<<endl;
    	  cout<<"cca is "<<em[i].cca<<endl;
    	  cout<<"total salary is "<<em[i].totalsalary<<endl;
    	getche();
    }
    }
    Last edited by Banfa; Mar 11 '14, 11:31 AM.
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    You don't say what the "many errors" are. The code does not look like it should have many errors.

    However, this is C++ code and I wonder if you are attempting to compile this as C code. If so, you will have many errors.

    Comment

    • donbock
      Recognized Expert Top Contributor
      • Mar 2008
      • 2427

      #3
      1. Line 4 defines struct employee. Line 14 tries to declare a variable of type employee. Slight mismatch there.
      2. Line 11 defines main as returning void. It should be int.
      3. You are mixing cin and gets.
      4. Lines 25 and 27 prompt for input, but lines 26 and 28 instead compute the values.

      Comment

      Working...