This blog is under construction

Monday 8 July 2013

C program to calculate income tax

Write a C program to calculate income tax.


  #include <stdio.h>
  int main() {
        double income, tax;

        /* get the income from the user */
        printf("Enter your income:");
        scanf("%lf", &income);

        /* calculate the income tax */
        if (income > 800000) {
                tax = 92000 + ((income - 180000) * 30)/100;
        } else if (income > 500000) {
                tax = 32000 + ((income - 180000) * 20)/100;
        } else if (income > 180000) {
                tax = ((income - 180000) * 10)/100;
        } else {
                tax = 0;
        }

        /* print the result */
        printf("Income tax for %.2lf is %.2lf\n", income, tax);
        return 0;
  }



  Output:
  jp@jp-VirtualBox:~/$ ./a.out
  Enter your income:750000
  Income tax for 750000.00 is 146000.00





See Also:

No comments:

Post a Comment