A C program to generate Salary Pay Slip for Staff – IGNOU MCA Assignment 2013

By | September 15, 2013

MASTER OF COMPUTER APPLICATIONS
Course Code : MCS-011
Course Title : Problem Solving and Programming
Assignment Number : MCA(1)/011/Assign/13
Assignment 2013 

 

An interactive C program to generate pay slips for the staff of size 12 employees (2 members are clerks, one computer operator, 6 salesmen, 3 helpers) , working in a small chemist retail shop.

 

#include<stdio.h>
#include<dos.h>
struct employee
{
    int NO;
    char NAME[10];
    int DESIGN_CODE;
    int DAYS_WORKED;
}EMP[12]={
         {1,"GANESH",1,25},
         {2,"MAHESH",1,30},
         {3,"SURESH",2,28},
         {4,"KALPESH",2,26},
         {5,"RAHUL",2,24},
         {6,"SUBBU",2,25},
         {7,"RAKESH",2,23},
         {8,"ATUL",2,22},
         {9,"DHARMESH",3,26},
         {10,"AJAY",3,26},
         {11,"ABDUL",3,27},
         {12,"RASHMI",4,29}
     };
void main()
{

    int EMPNO;
    void gen_payslip(int);
    clrscr();

    printf("ENTER THE EMPLOYEE NO TO GENERATE PAYSLIP : ");
    scanf("%d",&EMPNO);
    if(EMPNO>0 && EMPNO<13)
        gen_payslip(EMPNO);
    else
        printf("\nYOU HAVE ENTERED WRONG EMP NO. !!");
    getch();
}
void gen_payslip(int EMPNO)
{
 struct date D;
 char DESG[10];
 float NETPAY,BASIC,PF,PAYRATE,PTAX=200;
 getdate(&D);
 printf("\n\n\t\t\tSHREE KRISHNA CHEMISTS AND DRUGGIST");
 printf("\n\t\t\t\tSALARY MONTH %d %d\n",D.da_mon,D.da_year);
 printf("\n\n\tEMP.NO.: %d\t\tEMP.NAME: %s",EMPNO,EMP[EMPNO-1].NAME);
 switch(EMP[EMPNO-1].DESIGN_CODE)
 {
   case 1: PAYRATE=400;
       printf("\tDESIGNATION: CLERK");
       break;
   case 2: PAYRATE=300;
       printf("\tDESIGNATION: SALESMEN");
       break;
   case 3: PAYRATE=250;
       printf("\tDESIGNATION: HELPER");
       break;
   case 4: PAYRATE=350;
       printf("\tDESIGNATION: COMP.OPTR");
       break;
 }
 BASIC=PAYRATE*EMP[EMPNO-1].DAYS_WORKED;
 PF=BASIC/10;
 printf("\n\n\tDAYS WORKED: %d",EMP[EMPNO-1].DAYS_WORKED);
 printf("\t\tPAY RATE: %.0f\t\tGEN.DATE:%d/%d/%d ",PAYRATE,D.da_day,D.da_mon,D.da_year);
 printf("\n\t______________________________________________________________________");
 printf("\n\n\tEARNINGS\tAMOUNT(RS.)\t\tDEDUCTIONS\tAMOUNT(RS.)");
 printf("\n\t______________________________________________________________________");
 printf("\n\n\tBASIC PAY\t%.0f\t\t\tP.F.\t\t%.0f",BASIC,PF);
 printf("\n\n\t\t\t\t\t\tPROF.TAX\t%.0f",PTAX);
 printf("\n\n\t______________________________________________________________________");
 printf("\n\n\tGROSS EARN.\t%.0f\t\t\tTOTAL DEDUCT.\t%.0f",BASIC,PF+PTAX);
 NETPAY=BASIC-(PF+PTAX);
 printf("\n\t\t\t\t\t\tNET PAY\t\t%.0f",NETPAY);
 printf("\n\t______________________________________________________________________");

}

Code: -

  1. #include<stdio.h>
  2. #include<dos.h>
  3. struct employee
  4. {
  5.     int NO;
  6.     char NAME[10];
  7.     int DESIGN_CODE;
  8.     int DAYS_WORKED;
  9. }EMP[12]={
  10.          {1,"GANESH",1,25},
  11.          {2,"MAHESH",1,30},
  12.          {3,"SURESH",2,28},
  13.          {4,"KALPESH",2,26},
  14.          {5,"RAHUL",2,24},
  15.          {6,"SUBBU",2,25},
  16.          {7,"RAKESH",2,23},
  17.          {8,"ATUL",2,22},
  18.          {9,"DHARMESH",3,26},
  19.          {10,"AJAY",3,26},
  20.          {11,"ABDUL",3,27},
  21.          {12,"RASHMI",4,29}
  22.      };
  23. void main()
  24. {
  25.  
  26.     int EMPNO;
  27.     void gen_payslip(int);
  28.     clrscr();
  29.  
  30.     printf("ENTER THE EMPLOYEE NO TO GENERATE PAYSLIP : ");
  31.     scanf("%d",&EMPNO);
  32.     if(EMPNO>0 && EMPNO<13)
  33.         gen_payslip(EMPNO);
  34.     else
  35.         printf("\nYOU HAVE ENTERED WRONG EMP NO. !!");
  36.     getch();
  37. }
  38. void gen_payslip(int EMPNO)
  39. {
  40.  struct date D;
  41.  char DESG[10];
  42.  float NETPAY,BASIC,PF,PAYRATE,PTAX=200;
  43.  getdate(&D);
  44.  printf("\n\n\t\t\tSHREE KRISHNA CHEMISTS AND DRUGGIST");
  45.  printf("\n\t\t\t\tSALARY MONTH %d %d\n",D.da_mon,D.da_year);
  46.  printf("\n\n\tEMP.NO.: %d\t\tEMP.NAME: %s",EMPNO,EMP[EMPNO-1].NAME);
  47.  switch(EMP[EMPNO-1].DESIGN_CODE)
  48.  {
  49.    case 1: PAYRATE=400;
  50.        printf("\tDESIGNATION: CLERK");
  51.        break;
  52.    case 2: PAYRATE=300;
  53.        printf("\tDESIGNATION: SALESMEN");
  54.        break;
  55.    case 3: PAYRATE=250;
  56.        printf("\tDESIGNATION: HELPER");
  57.        break;
  58.    case 4: PAYRATE=350;
  59.        printf("\tDESIGNATION: COMP.OPTR");
  60.        break;
  61.  }
  62.  BASIC=PAYRATE*EMP[EMPNO-1].DAYS_WORKED;
  63.  PF=BASIC/10;
  64.  printf("\n\n\tDAYS WORKED: %d",EMP[EMPNO-1].DAYS_WORKED);
  65.  printf("\t\tPAY RATE: %.0f\t\tGEN.DATE:%d/%d/%d ",PAYRATE,D.da_day,D.da_mon,D.da_year);
  66.  printf("\n\t______________________________________________________________________");
  67.  printf("\n\n\tEARNINGS\tAMOUNT(RS.)\t\tDEDUCTIONS\tAMOUNT(RS.)");
  68.  printf("\n\t______________________________________________________________________");
  69.  printf("\n\n\tBASIC PAY\t%.0f\t\t\tP.F.\t\t%.0f",BASIC,PF);
  70.  printf("\n\n\t\t\t\t\t\tPROF.TAX\t%.0f",PTAX);
  71.  printf("\n\n\t______________________________________________________________________");
  72.  printf("\n\n\tGROSS EARN.\t%.0f\t\t\tTOTAL DEDUCT.\t%.0f",BASIC,PF+PTAX);
  73.  NETPAY=BASIC-(PF+PTAX);
  74.  printf("\n\t\t\t\t\t\tNET PAY\t\t%.0f",NETPAY);
  75.  printf("\n\t______________________________________________________________________");
  76.  
  77. }

SCREEN SHOTS :-

MCS011_Q6

MCS011_Q6_Output

Leave a Reply