C program to calculate income tax using default arguments
#include<stdio.h> #include<conio.h> struct income_tax { int itax, int icm;}; #define income_tax(...) income_tax((struct income_tax) {.itax=0,.icm, __VA_ARGS__}) int main(int itax, int icm) { printf ("Enter your income: "); scanf ("%d", &icm); if (icm >= 250000 && icm <= 500000) { itax = itax + 0.09 * (icm - 250000); } if (icm >= 500000 && icm <= 1000000) { itax = itax + 0.20 * (icm - 500000); } if (icm >= 1000000) { itax = itax + 0.30 * (icm - 1000000); } printf ("Your net income tax is: %d", itax); return 0; }
Output:
Enter your income: 4000000
Your net income tax is: 13500