Created
June 21, 2019 08:10
-
-
Save AnupRaj/70575584ccafbf587291c49cc2e4159e to your computer and use it in GitHub Desktop.
c program apply tax on salary
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() | |
{ | |
long int salary; //to store salary | |
long int newsalary; //to store temp salary | |
float tax; //to store tax | |
//char debug_msg[250]; // short msg | |
//input salary | |
printf("Enter yearly salary: "); | |
scanf("%ld",&salary); | |
tax =0; | |
newsalary=salary; | |
//debug_msg= ""; | |
printf("\nDebug Msg: starting the ride ... "); | |
// 0 to 999,999 = no tax | |
// 100,000 to 149,999 = 15% tax | |
// 150,000 and above 25% tax | |
//tax calculations | |
if(salary>=0 && salary < 100000){ | |
// tax = salary*1/100; | |
// no tax .. nothing to do with salary | |
// tax is still 0 up there above at line 12 ;) | |
newsalary = salary; | |
salary = newsalary; | |
// debug_msg = "first if statement "; | |
printf("\nDebug Msg: hello from first if statement ;)"); | |
}else if(salary >= 100000 && salary<150000){ | |
tax = salary*15/100; | |
// tax = tax + (salary-150000)*15/100; | |
newsalary = salary - tax; | |
salary = newsalary; | |
// debug_msg .= "second if statement "; | |
printf("\nDebug Msg: @ 2nd if statement"); | |
} | |
else if (salary > 150000){ | |
tax = salary*25/100; | |
// | |
// tax = tax + (600000)*15/100; | |
// | |
newsalary = salary - tax; | |
// debug_msg .= "third if statement "; | |
salary = newsalary; | |
printf("\nDebug Msg: max tax applied"); | |
} | |
else{ | |
// debug_msg .= "void "; | |
printf("\nDebug Msg: @ Void"); | |
salary = newsalary; | |
printf("\nSalary from Void: %ld\n",salary); | |
} | |
salary = newsalary; | |
printf("\nSalary: %ld\n",salary); | |
printf("\nTax: %0.2f\n",tax); | |
printf("\nDebug Msg: reached at end "); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment