-1

This program is supposed to calculate two tax values using pointers in the calculateTaxes function then display them in the displayTaxes function. My question is after they are calculated then put into the pointers I have, how do I go about displaying them in the displayTaxes function?

#include <stdio.h>


int inputTotalSales();
int calculateTaxes(int sales,int *statePtr,int *countyPtr);
void displayTaxes(int state,int county);
int main()

{
    int sales,state,county;

    sales=inputTotalSales();

    printf("Sales are: %d\n", sales);

    calculateTaxes(sales,&state,&county);

    displayTaxes(state,county);



}

int inputTotalSales()
{
    int sales;
    printf("Enter monthly sales: ");
    scanf("%d", &sales);
    return sales;
}

int calculateTaxes(int sales,int *statePtr,int *countyPtr)
{
    int state=0.04;
    int county=0.02;


    state= sales*state;
    county=sales*county;

    *statePtr=state;
    *countyPtr=county;


}

void displayTaxes(int state,int county)
{

    int total; 
    total = county+state;

    printf("Taxes for your sales are: \n");
    printf("STATE: %d\n COUNTY: %d\n TOTAL: %d",state,county,total);



}
Jaruto
  • 13
  • 6

1 Answers1

1

The problem here does not come from your pointer, they are working fine I think

But you are computing state and county as integer, but they should be float (just like statePtr value and countyPtr value)

Try changing everything into float instead of integer.

Ilphrin
  • 54
  • 4