Employe details to list out - Payslips

This is a discussion on Employe details to list out - Payslips within the C Programming forums, part of the General Programming Boards category; hi friends, In the below code errors are displayed it should not calculateting PF and some others also let see ...

  1. #1
    Registered User
    Join Date
    Mar 2007
    Posts
    2

    Employe details to list out - Payslips

    hi friends,

    In the below code errors are displayed it should not calculateting PF and some others also let see below code if error please specify where.


    Code:
    #include<stdio.h>
    #include<conio.h>
    void main()
    {
    int n,i,k;
    struct employee
    {
    char name[50],des[30],mon[10],level;
    int empid,accno;
    float hra,da,cca,ca,gpf,grossal,totdeduc,netsal,basic;
    }emp[10];
    clrscr();
    printf("ENTER THE NUMBER OF EMPLOYEE: ");
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
    printf("\n ENTER NAME OF THE EMPLOYEE:");
    scanf("%s",emp[i].name);
    printf("\n ENTER DESIGANTION OF THE EMPLOYEE:");
    scanf("%s",emp[i].des);
    printf("\n ENTER MONTH:");
    scanf("%s",emp[i].mon);
    printf("\n ENTER EMPLOYEE ID:");
    scanf("%d",&emp[i].empid);
    printf("\n ENTER ACCNO:");
    scanf("%d",&emp[i].accno);
    printf("\nENTER BASIC PAY: ");
    scanf("%f",&emp[i].basic);
    printf("ENTER CITY LEVEL: ");
    scanf("%s",&emp[i].level);
    }
    for(i=1;i<=n;i++)
    {
    emp[i].hra=emp[i].basic*0.30;
    if(emp[i].basic<=6500)
      emp[i].ca=100;
    else
    {
      if(emp[i].basic>6500&&emp[i].basic<=8000)
      emp[i].ca=400;
      else
      emp[i].ca=800;
    }
    emp[i].da=emp[i].basic/2;
    if(emp[i].level=='a'||emp[i].level=='A')
      emp[i].cca=400;
    else
    {
      if(emp[i].level=='b'||emp[i].level=='B')
      emp[i].cca=100;
      else
      emp[i].cca=50;
    }
    emp[i].gpf=emp[i].basic * 0.075;
    emp[i].grossal=emp[i].basic+emp[i].hra+emp[i].da+emp[i].cca;
    emp[i].totdeduc=emp[i].gpf;
    emp[i].netsal=emp[i].grossal-emp[i].totdeduc;
    }
    
    for(i=1;i<=n;i++)
    {
    do
    {      clrscr();
      printf("\n\t\t V R SIDDHARTHA ENGINEERNG COLLEGE");
      printf("\n\t\t\t KANURU::VIJAYAWADA-7\n");
      printf("\n\t\t\t\t PAY SLIP");
      printf("\n\t\t\t************************");
      printf("\n\t\t\t Salary Slip for %s ",emp[i].mon);
      printf("\n\t\t\t***********************");
      printf("\n\n \tNAME: %s \t\t\tEMPID: %d ",emp[i].name,emp[i].empid);
      printf("\n\n \tDESIGNATION:%s \t\tACCNO:%d",emp[i].des,emp[i].accno);
      printf("\n---------------------------------------------\n");
      printf("<----------EARNINGS---------->    <-------DEDUCTIONS------------>\n");
      printf("\n BASIC=%f \t\t\t\tP.F.=%.2f",emp[i].basic,emp[i].gpf);
      printf("\n\n D.A=%.2f \t\t\t\tINCOME TAX=",emp[i].da);
      printf("\n\n H.R.A=%.2f \t\t\t\tP.F. LOAN=",emp[i].hra);
      printf("\n\n C.C.A=%.2f \t\t\t\tL.I.C=",emp[i].cca);
      printf("\n\n-------------------------------------------------");
      printf("\n\n GROSS SALARY=%.2f \t\tTOTAL DEDUCTIONS=%.2f " ,emp[i].grossal,emp[i].totdeduc);
      printf("\n\n---------------------------------------------------");
      printf("\n\n\t\t\t NET SALARY=%.2f",emp[i].netsal);
      printf("\n\n---------------------------------------------------");
      printf("\n\n\n\t\t\t\t\t\tEMPLOYEE SIGNATURE");
      printf("\n\n\nPRESS 1 TO NEXT ......");
      scanf("%d",&k);
    }while(k==2);
    }
    getch();
    }

    thanks in advance

  2. #2
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    whats the error message, or explain again more clearly what is happening that 'shouldnt' be. the code is very unreadable.

  3. #3
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Pasting up some input and output that shows the problem, would be great, as well as making your description more specific. I understand that English is not your first language. Maybe you could get someone to help post a follow-up?

    Better indentation especially in the upper parts of the code, would help make it more readable - and int main() with a return 0 would be good.

    Adak
    Last edited by Adak; 04-02-2007 at 12:37 AM.

  4. #4
    Registered User
    Join Date
    Mar 2007
    Posts
    2
    hi friends,

    i m not getting INCOME TAX, LOAN, LIC result values after compile and i m not know how to calculate incom tax, loan and LIC in code base.


    Thanks

  5. #5
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Quote Originally Posted by jamesbond008 View Post
    hi friends,

    i m not getting INCOME TAX, LOAN, LIC result values after compile and i m not know how to calculate incom tax, loan and LIC in code base.


    Thanks
    I don't know your income tax percentage or scale. This is the only calculation of it I see in your code:
    Code:
    emp[i].da=emp[i].basic/2;
    which indicates a 50% income tax rate on the employee's basic pay, or:

    Income Tax Amount = Taxable Income * (income tax percent rate / 100)

    Adak

  6. #6
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Code:
    for(i=1;i<=n;i++)
    Arrays in C start a 0, not 1. Your array should read:
    Code:
    for(i=0;i<n;i++)

    Quzah.
    Hope is the first step on the road to disappointment.

  7. #7
    Registered User
    Join Date
    Mar 2005
    Posts
    37
    Quote Originally Posted by jamesbond008 View Post
    hi friends,

    i m not getting INCOME TAX, LOAN, LIC result values after compile and i m not know how to calculate incom tax, loan and LIC in code base.


    Thanks
    Hey
    Why don't you tell us about the logic that you have used in your pgm, rather than cut and past of code what you have got.. ?
    It very much looks like an assignment problem and as the rule of this board, people won't help you do your assignment. however they will be more than happy to help you in understand the the problem and give you directions..!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Unknown memory leak with linked lists...
    By RaDeuX in forum C Programming
    Replies: 6
    Last Post: 12-07-2008, 03:09 AM
  2. instantiated from here: errors...
    By advocation in forum C++ Programming
    Replies: 5
    Last Post: 03-27-2005, 08:01 AM
  3. How can I traverse a huffman tree
    By carrja99 in forum C++ Programming
    Replies: 3
    Last Post: 04-28-2003, 05:46 PM
  4. Linked list with two class types within template.
    By SilasP in forum C++ Programming
    Replies: 3
    Last Post: 02-09-2002, 05:13 AM
  5. singly linked list
    By clarinetster in forum C Programming
    Replies: 2
    Last Post: 08-26-2001, 10:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21