i made a property tax program but now i have to use it with pointers. i have to use 3 functions inputtotalsales,calculatetaxes,and displaytaxes.It was easy for me to do this the regular way but im having an issue with pointers . im getting errors saying redeclaration of statetax and countytax they were previously declared. What am i doing wrong why can i do it this way.

#include <stdio.h>
    float inputtotalsales();
    float calctaxes(float*,float* );

    void displaytaxes(float,float);

     int main()

    {
      float totalsale;
      float statetax;
      float countytax;

      totalsale =inputtotalsales();
      calctaxes(&statetax,&countytax);

      displaytaxes(statetax,countytax);
      return 0;
    }

      float inputtotalsales()
   {

      float totalsale;

     printf("Enter total sales for month");
      scanf("%2f",& totalsale);

     return totalsale;
    } 

     float calcstaxes(float *statetaxptr,float*countytaxptr)
    { float totalsale,statetax, countytax;//errors here

      float statetax= totalsale*.04;
      float countytax=totalsale *.02;

     *statetaxptr=statetax; 
     *countytaxptr=countytax;

     } 

    void      displaytaxes(float statetax,float countytax)
     {

      printf("\n State tax is %.2f",statetax);
      printf("\n County tax is %.2f",countytax);
      printf("\n Total tax is %.2f",statetax+countytax);
     }

One problem you have is here:

 float calcstaxes(float *statetaxptr,float*countytaxptr)
{ 
       float totalsale,statetax, countytax;//errors here
      float statetax= totalsale*.04;
      float countytax=totalsale *.02;
     *statetaxptr=statetax; 
     *countytaxptr=countytax;
 } 

statetax and countytax are declared twice. This is one danger of declaring multiple variables on one line. Basically what you've done is this:

 float calcstaxes(float *statetaxptr,float*countytaxptr)
{ 
    float totalsale;
    float statetax;
    float countytax;
     float statetax= totalsale*.04;
     float countytax=totalsale *.02;
     *statetaxptr=statetax; 
     *countytaxptr=countytax;
 }

See if this helps:

 float calcstaxes(float *statetaxptr,float*countytaxptr)
{ 
    float totalsale;
    float statetax;
    float countytax;
     statetax= totalsale*.04;
     countytax=totalsale *.02;
     *statetaxptr=statetax; 
     *countytaxptr=countytax;
 }
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.