hey all i am new to all this languages and Computer sciences so if you help me
i am trying to write a code and its constantly giving me errors here is the code
at line 10 , 102 , 115 tell me how to fix it.. waiting...

#include<iostream.h>


void get_input(double sal[][2], int numemps);
void calc_net_sal(double sal[][2], int numemps);
void find_unluckies(double sal[][2], int numemps, int lucky[]);
void mark_if_unlucky(double sal[][2], int numemps, int lucky[], int upperbound, int empnbr);
void print_unluckies(int lucky[], int numemps)

void main(void)
{
     const int arraysize=100;
     double sal[arraysize][2];
     int lucky[arraysize] = {0};
     int numemps; 

     // getting input abt the total number of employs
     cout<<"\n please enter the total number of employs in your company :";
     cin>>numemps;
     cout<<"\n";

     /* read the gross salaries of the employes in the array 'sal'*/

     get_input(sal, numemps);

     // calculation of net salaries of the employees and storing them in array

     cout<<"\n\n locating the unlucky employees...";
     find_unluckies(sal, numemps, lucky);
     print_unluckies(lucky, numemps);

     //printing the unlucky employees
     cout<<"\n\n printing the unlucky employees";
     print_unluckies(lucky, munemps);
}

void get_input(double sal[][2], int numemps)
{
     for(int i = 0; i < numemps; i++) //numemps is local for this function
     {
             cout<<"\n please enter the gross salary for employee number "<<i<<":";
             cin>> sal[i][0];
     }
}

void calc_net_sal(double sal[][2], int numemps)
{
     for(int i=0; i < numemps; i++)  //numemps is local for this function
     {
             if(sal[i][0] >= 0 && sal[i][0] <= 5000)
             {
                          //no tex deduction
                  sal[i][1]= sal[i][0];
             }
             else if(sal[i][0] >= 5001 && sal[i][0] <=10000)
             {
                  //5% tax will be deducted
                  sal[i][1] = sal[i][0] -(.05 *sal[i][0]);
             }
             else if(sal[i][0] >=10001 && sal[i][0] <=20000)
             {
                  //10% tax deduction
                  sal[i][1] = sal[i][0] -(.10 * sal[i][0]);
             }
             else if(sal[i][0] >=20001)
             {
                  //15% tax deduction
                  sal[i][1] = sal[i][0] -(.15 * sal[i][0]);
             }
             else
             {
                  //no need to do anything here
             }
     }
}

void find_unluckies(double sal[][2], int numemps, int lucky[])
{
     for(int i = 0 ; i < numemps; i++) //numemps is local for this function
     {
             if(sal[i][0] >= 0 && sal [i][0] <= 5000)
             {
                          //no need to chk for unlucky employees
             }
             else if(sal[i][0] >= 5001 && sal[i][0] <= 10000)
             {
                  mark_if_unlucky(sal, numemps, lucky, 5001, i);
             }
             else if(sal[i][0] >= 10001 && sal[i][0] <= 20000)
             {
                  mark_if_unlucky(sal, numemps, lucky, 10001, i);
             }
             else if(sal[i][0] >= 20001)
             {
                       mark_if_unlucky(sal, numemps, lucky, 20001, i);
             }
     }
}

void mark_if_unlucky(double sal[][2], int numemps[], int lucky [], int upperbound, int empnbr)
{
     for( int i = 0 ; i < numemps; i++)
     {

             if(sal[i][0] < upperbound && sal[i][1] >= sal[empnbr][1])
             {
                          lucky[empnbr] = 1; // employee marked as unlucky
                          break;
             }
     }
}

void print_unluckies(int lucky[], int numemps)
{
     for(i = 0; i < numemps; i++)
     {
           if(lucky[i] == 1)
           {
                       cout<<"\n employee no. : <<i";
           }
     }
}

Line 10: Often if the line itself is fine, look at previous lines. In this case you neglected to terminate the previous function prototype with a semicolon. The error wasn't detected until line 10, where it caused the compiler to puke.

Line 102: numemps is an array, but you compare it with an int. The two types are not compatible.

Line 115: i was never declared. Line 115 should look exactly like line 102. The error from line 102 won't occur because in this function, numemps is just an int and not an array.

Edited 3 Years Ago by deceptikon

so what should i do about line 10 and i fixed line 115 but at line 102 it is saying 102 C++ forbids comparison between pointer and integer.. and how to fix it

so what should i do about line 10

Fix line 8.

but at line 102 it is saying 102 C++ forbids comparison between pointer and integer..

That's basically the same thing I said. i is an int and numemps is an array. You can't compare the two because it's not meaningful. Change numemps to an int just like in print_unluckies(); you clearly know how it's supposed to work because you've done it correctly in another function.

tanx alot.. and when i fixed line 8 its now giving me an error at line 11 which says 'main' must return 'int'.

which says 'main' must return 'int'.

So return int instead of void. Seriously, use some common sense; these errors aren't exactly being cryptic. I'd explain why void main is wrong, but if your compiler is rejecting it outright then knowing would only be academic. So if you're interested, just search Google for "void main wrong".

Edited 3 Years Ago by deceptikon

This question has already been answered. Start a new discussion instead.