declaration syntax error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dianaroslan
    New Member
    • Mar 2010
    • 5

    declaration syntax error

    There are three errors in coding during compile. one of them is the declaration syntax error. can help me to finish coding this? really need help from anyone who knows. i have some problem with my total function and declaration.

    Code:
    #include <iostream>
    #include <conio>
    
    const int listSize=1;
    
     struct employeeInfo
     {
       char name[50], address[100],noPhone[50];
       int age,ICnum;
       float salary,totalSalary,totalOT,hour;
     };
    
     void getData (employeeInfo Data[],int listSize);
     void total (employeeInfo Data[],int listSize);
     void printReport (employeeInfo Data[],int listSize);
    
     int main()
     {
    
       textcolor(13);
       textbackground(BLUE);
       cprintf("                                                  ");cout<<"\n";
       cprintf("      **********************************  ");cout<<"\n";
       cprintf("      *                                *          ");cout<<"\n";
       cprintf("      * PREPARED BY : DIANA & FARAH    *          ");cout<<"\n";
       cprintf("      *                                *          ");cout<<"\n";
       cprintf("      *                                *          ");cout<<"\n";
       cprintf("      * CLASS GROUP : CSD2S4           *          ");cout<<"\n";
       cprintf("      *                                *          ");cout<<"\n";
       cprintf("      * PROJECT 138 : EMPLOYEE         *          ");cout<<"\n";
       cprintf("      *               MANAGEMENT       *          ");cout<<"\n";
       cprintf("      *               SYSTEM           *          ");cout<<"\n";
       cprintf("      *                                *          ");cout<<"\n";
       cprintf("      *                                *          ");cout<<"\n";
       cprintf("      * LECTURER    : EN MALIK BIN     *          ");cout<<"\n";
       cprintf("      *               BIN MOHD RICK    *          ");cout<<"\n";
       cprintf("      *                                *          ");cout<<"\n";
       cprintf("      **********************************          ");cout<<"\n";
       cprintf("                                                  ");cout<<"\n";
       cout<<endl;
       textcolor(11);
       textbackground(YELLOW);
    
     	employeeInfo employeeData[listSize];
       getData(employeeData,listSize);
       cout<<"ENTER YOUR LATEST SALARY"<<endl;
       cin>>employeeData[listSize].salary;
    
      
    
        cout<<endl;
       textcolor(11);
       textbackground(YELLOW);
       cout<<"_____________________________________________________________________________"<<endl;
       cprintf("                            EMPLOYEE FORM                                   ");cout<<"\n";//company name
       cprintf("                      EMPLOYEE MANAGEMENT SYSTEM                            ");cout<<"\n";//company name
       cprintf("                      DISPLAY THE EMPLOYEE DATA                             ");cout<<"\n";//company name
       cout<<"_____________________________________________________________________________"<<endl;
    
    
       printReport (employeeData,listSize);
    
    
    	getch();
       return 0;
     }
    
     void getData (employeeInfo Data[],int listSize)
     {
     	for(int i=0;i<listSize;i++)
       	{
          	cout<<"ENTER YOUR NAME :";
             cin>>ws;
             cin.getline(Data[i].name,50);
             cout<<"YOUR AGE  :";
             cin>>Data[i].age;
             cout<<"YOUR PHONE NUMBER  :";
             cin>>ws;
             cin.getline(Data[i].noPhone,50);
             cout<<"IC NUMBER :";
             cin>>Data[i].ICnum;
             cout<<"YOUR ADDRESS : ";
             cin>>ws;
             cin.getline(Data[i].address,100);
             
          }
     }
    
     void total(employeeInfo Data[],int listSize)
     {
    
    
      if (Data[listSize].hour==1)
       	Data[listSize].totalOT=3.0;
       else if (Data[listSize].hour>1 && Data[listSize].hour<5)
       	Data[listSize].totalOT=5.0;
       else
       	Data[listSize].totalOT=0.0;
    
      for(int j=0;j>1;j++)
     	{
    
       	cout<<"over time"<<endl;
    		cin>>Data[listSize].hour;
    		Data[j].totalSalary=Data[j].salary+Data[j].totalOT;
       }
    
    
    
     void printReport (employeeInfo Data[],int listSize)
    {
    		cout<<"NAME          :"<<Data[listSize].name<<endl;
          cout<<"AGE           :"<<Data[listSize].age<<endl;
          cout<<"PHONE NUMBER  :"<<Data[listSize].noPhone<<endl;
          cout<<"IC NUMBER     :"<<Data[listSize].ICnum<<endl;
          cout<<"ADDRESS       :"<<Data[listSize].address<<endl;
    }
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    If you want help with compilation errors then
    1. Post the actual errors
    2. Indicate which lines of you listing the occur on

    Comment

    • dianaroslan
      New Member
      • Mar 2010
      • 5

      #3
      still have error in that coding
      the errors are
      declaration syntax error at line 111

      declaration missing ; at line 118

      compound statement missing } at line 118

      really need help

      Comment

      • Banfa
        Recognized Expert Expert
        • Feb 2006
        • 9067

        #4
        Your function total starting at line 89 has no closing }

        By the way remember if you declare any array of type T and size N

        T array[N];

        then valid indexes for array are 0 - (N-1). You declare an array of size 1 at line 44 but in a lot of your functions you access it using an index of 1 which is out of range.

        Comment

        Working...