C Practice Program on TCS

Consider a scenario that TCS find their salary using these conditions:

Number of Packages Transferred: TCS pays 5000 per package delivery to Permanent Employees and 3000 per package delivery to Temporary Employees.
Travel Allowance: TCS provide 500 per travel as allowance and 300 per travel as an allowance to Temporary Employees.
Shift: TCS pays 10% increment, who did night shifts.

So write a program in C to calculate employees basic pay.

Also, TCS use Grading System for its employee to calculate net pay (consider grade is entered by a user)
A1 5%
A2 10%
A3 15%


#include<stdio.h>
int TCS(char employee, int allowance, char grade, int shift)
{
int basicpay, pd, da;
if( employee == 'p' || employee == 'P')
{
printf("How many package he delivered?");
scanf("%d", &pd);
basicpay = (5000 * pd);
if(allowance == 1)
{
printf("For how many days he got a travel allowance");
scanf("%d", &da);
basicpay = (basicpay * (500 * da) );
}
if(shift == 1)
{
printf("For how many he days did night shift ");
scanf("%d", &shift);
basicpay = (basicpay * (shift * 0.1) );
}
if(grade == 1 )
{
basicpay = (basicpay*0.05);
}
else if(grade == 2 )
{
basicpay = (basicpay*0.1);
}
else if(grade == 3 )
{
basicpay = (basicpay*0.15);
}
printf("His net pay is %d", basicpay);
}
else if( employee == 't' || employee == 'T')
{
printf("How many package he delivered?");
scanf("%d", &pd);
basicpay = (3000 * pd);
if(allowance == 1)
{
printf("For how many days he got a travel allowance");
scanf("%d", &da);
basicpay = (basicpay * (300 * da) );
}
if(shift == 1)
{
printf("For how many he days did night shift ");
scanf("%d", &shift);
basicpay = (basicpay * (shift * 0.1) );
}
if(grade == 1 )
{
basicpay = (basicpay*0.05);
}
else if(grade == 2 )
{
basicpay = (basicpay*0.1);
}
else if(grade == 3 )
{
basicpay = (basicpay*0.15);
}
printf("His net pay is %d", basicpay);
}
else
{
printf("Invalid Input");
}
}
void main()
{
char employee;
int allowance = 0;
int shift = 0;
int grade;
printf("Enter the Employee is Permanent or Temporary\n");
printf("Enter P for Permanent or T for Temporary \n");
scanf("%c",&employee);
printf("They get Daily Allowance \n");
printf("0 for No and 1 for Yes \n");
scanf("%d",&allowance);
printf("Did He did any night shift? \n");
printf("0 for No and 1 for Yes \n");
scanf("%d",&shift);
printf("What is his grade? \n");
printf(" Enter 1 for A1, Enter 2 for A2 or Enter 3 for A3 \n");
scanf("%d",&grade);
TCS(employee, allowance, grade, shift );
}
view raw tcs-program.c hosted with ❤ by GitHub

Comments

Popular posts from this blog

Pseudocode to Check, Number is Odd or Even

How to Create Marksheet in C

C Program to Calculate Acceleration