• #include<stdio.h>
    int main()
    {
       int grossPay,tax1,tax2,tax3,extraHour,workingHour=40,TworkingHour,pay1,pay2,income1,totalTax,netPay,grossPay;
       printf("Enter the hours you have worked today");
       scanf(" %d",&TworkingHour);
       extraHour=TworkingHour-workingHour;
       pay1=workingHour*12;
       pay2=extraHour*18;
       grossPay=pay1+pay2;
       if(grossPay<=300)
       {
           tax1=grossPay*0.15;
           totalTax=tax1;
           netPay=grossPay-totalTax;
           printf("GROSS PAY$%d/nTAX$%d/nNET PAY$%d",grossPay,tax1,netPay);
       }
       else if(grossPay>300 && grossPay<=450)
       {
           tax1=300*0.15;
           income1=grossPay-300;
           tax2=income1*0.20;
           totalTax=tax1+tax2;
           netPay=grossPay-totalTax;
           printf("GROSS PAY$%d/nTAXES$%d,$%d/nNET PAY$%d",grossPay,tax1,tax2,netPay);
       }
       else if(grossPay>450)
       {
           tax1=300*0.15;
           tax2=150*0.20;
           income1=grossPay-450;
           tax3=income1*0.25;
           totalTax=tax1+tax2,tax3;
           netPay=grossPay-totalTax;
           printf("GROSS PAY$%d/nTAXES$%d,$%d,$%d/nNET PAY$%d",grossPay,tax1,tax2,tax3,netPay);
       }
       else
       {
           printf("Invalid pay");
       }
    
       return 0;
    }
    

    Screenshot (80).png



  • I found the following stackoverflow answer: https://stackoverflow.com/questions/8124682/error-redeclaration-with-no-linkage

    I am going to quote the quote

    "You can't have two global variables with the same name in C program. C might allow multiple definitions in the same file scope through the tentative definition rule, but in any case all definitions will refer to the same variable."

    So grossPay is probably declared somewhere else already.

    I hope this helps.



  • I found the following stackoverflow answer: https://stackoverflow.com/questions/8124682/error-redeclaration-with-no-linkage

    I am going to quote the quote

    "You can't have two global variables with the same name in C program. C might allow multiple definitions in the same file scope through the tentative definition rule, but in any case all definitions will refer to the same variable."

    So grossPay is probably declared somewhere else already.

    I hope this helps.



  • you are right bro I got it just look at the last variable in the same line.