Friday, March 28, 2014

Sample Program to calculate and print Gross Salary after deduction of taxes from the total salary

#include<stdio.h>
#include<stdlib.h>
void line()
{
int i,j;
printf("\n");
for(i=1;i<=42;i++)
printf("=");
}
void header()
{
printf("\n");
printf("Built and Designed by Arslan Malik\n\n www.CworldbyAS.blogspot.com");
printf("\n");
}
int main()
{
line();
header();
line();

int a;
printf("Enter Basic Salary = ");
scanf("%d",&a);
if (a<5000)
    {


    printf("HRA is 3%% of B.S =%d \n",a/100*3);
    printf("M.A is 2%% of B.S =%d \n",a/100*2);
    printf("D.A is 2%% of B.S =%d \n",a/100*2);
    printf("T.A is 1%% of B.S =%d \n",a/100*1);
    printf("TAX is 0.5%% of B.S = %d \n",a/100*1/2);
    printf("Fund is 5%% of B.S  = %d\n",a/100*5);
    printf("Utility Bills is 4%% of B.S=%d\n",a/100*4);
    printf("\nGross Salary = %d\n",a-(a/100*3+a/100*2+a/100*2+a/100*1+a/100*1/2+a/100*5+a/100*4));
    }
    else if (a>=5000 && a<=30000)
        {
            printf("HRA is 5%% of B.S = %d\n",a/100*5);
            printf("M.A is 3%% of B.S = %d\n",a/100*3);
            printf("D.A is 3%% of B.S = %d\n",a/100*3);
            printf("T.A is 2%% of B.S = %d\n",a/100*2);
            printf("TAX is 2%% of B.S = %d\n",a/100*2);
            printf("Fund is 8%% of B.S =%d\n",a/100*8);
            printf("Utility Bills is 5%% of B.S =%d\n",a/100*5);
            printf("\nGross Salary = %d\n",a-(a/100*5+a/100*3+a/100*3+a/100*2+a/100*2+a/100*8+a/100*5));

        }
    else if (a>30000)
    {

        printf("HRA is 7%% of B.S = %d\n",a/100*7);
        printf("M.A is 4%% of B.S = %d\n",a/100*4);
        printf("D.A is 4%% of B.S = %d\n",a/100*4);
        printf("T.A is 3%% of B.S = %d\n",a/100*3);
        printf("TAX is 3%% of B.S = %d\n",a/100*3);
        printf("Fund is 10%% of B.S = %d\n",a/100*10);
        printf("Utility Bill is 10%% of B.S = %d\n",a/100*10);
        printf("\nGross Salary = %d\n",a-(a/100*7+a/100*4+a/100*4+a/100*3+a/100*3+a/100*10+a/100*10));
    }


return 0;
}

No comments:

Post a Comment