I am trying to create a project, which will compute the yearly and monthly rate of taxes to be paid by a person earning
a given gross yearly salary, knowing the rates for NI contributions, pension contributions, and income tax.
The problem i am having is i dont think the main program is calling any of the procedures, as far as i can tell its ok but im new to this...
im using a borland compiler btw.
here the code so far:

#include <stdio.h>


double Net(double salary, double *NI)
{
*NI = ((salary/100)*6);
return *NI;
}

double Pension (double *pension,double salary)
{
*pension = ((salary/100)*2);
return *pension;
}

double taxable(double *tax, double NI, double salary, double pension)
{
*tax = (salary - pension -NI);
return *tax;
}


double taxdue(double *taxing, double *tax)

    {
    double tdnew, tdold;
    *taxing = 0;
    {
    if (*tax <= 4000)
             return *taxing;
    else
          *tax = *tax - 4000;

    }
    {
    if ((*tax -11000) > 0)
       tdnew = ((11000/100)*17);
    else
    return *taxing;
    }
    *taxing = tdnew;
    tdold = tdnew;
    *tax = *tax - 11000;
    {
    if  ((*tax - 15000) > 0)
        tdnew = (((15000/100)*25) + tdold);
    else return *taxing;
    }
    *tax = *tax -15000;
    *taxing = tdnew;
    tdold = tdnew;
    {
    if (*tax < 0)
       return *taxing;
       else
       tdnew = (((*tax/100)*40) + tdold) ;
       *taxing = tdnew;
       return *taxing;
    }
}


int main(void)
{
double i;
double n;
double p;
double t;
double td;

{
printf ("Input gross yearly salary:  ");
scanf("%f",&n);


    double Net(double n,double *i);
    double Pension (double *p, double n);
    double taxable (double *t, double i, double n, double p);
    double taxdue (double *td, double *t);
}
{
printf( "\n\n Contributions:  ");
printf("\n\t Monthly \t  Yearly\n");
printf("NI \t" "%f",(i/12));
printf("\t");
printf("%f",i);
printf("Pension \t" "%f",(p/12),"\t");
printf("%f",p );
printf("Tax due \t" "%f",(td/12),"\t" "%f",td);
}
return ;
}

Recommended Answers

All 3 Replies

>double Net(double n,double *i);
>double Pension (double *p, double n);
>double taxable (double *t, double i, double n, double p);
>double taxdue (double *td, double *t);
These aren't function calls, they're function declarations. You call those functions like so:

Net ( n, &i );
Pension ( &p, n );
taxable ( &t, i, n, p );
taxdue ( &td, &t );

Thanks allot, for that, im still having probelms though, the program just seems to run without calling the functions, even after your changes, any ideas??

>scanf("%f",&n);
%f means float for scanf, not double. Try changing it to %lf and see if your output looks better.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.