Powered By Blogger

Friday, April 27, 2012

Program : 16


PROGRAM - 16

a)  Write a program to accept the element of the structure as: Employee-name and Basic pay.
Display the same structure along with the DA, CCA and Gross Salary for 5 employees.
Note: DA=51% of basic pay, CCA= Rs.100. Consolidated.

Program:

#include<stdio.h>
#include<conio.h>
void main()
{
     int i;
     struct emp
     {
        char name[20];
        int basic;
        int cca;
        int da;
        float gross;
     };
     struct emp e[5];
     clrscr();
     printf("\n enter emp name and basic:");
     for(i=0;i<5;i++)
     {
       scanf("%s %d",e[i].name,&e[i].basic);
       e[i].da=e[i].basic*0.51;
       e[i].cca=100;
       e[i].gross=e[i].basic+e[i].da+e[i].cca;
     }
     for(i=0;i<5;i++)
     {
       printf("\nName=%s\nBasics=%d\nCca=%d\nda=%d \nGross=%f",e[i].name,                          e[i].basic,e[i].cca,e[i].da,e[i].gross);
     }
     getch();
}
/*
INPUT:
 enter emp name and basic:
MICHAEL
1000
OUTPUT:
Name=MICHAEL
Basics=1000
Cca=100
da=510
Gross=1610.000000
*/


b)  Define a structure to store employee’s data with the following specifications: Employee-number, Employee-Name, Basic Pay, and Date of joining.

  •   Write a function to store 10 employee details.
  •   Write a function to implement the following rules while revising the basic pay.
i) If basic pay<= Rs. 5000 then increase it by 15%.
ii) If basic pay > Rs. 5000 and <=Rs. 25000 then      it    increase by 10%.
iii) If basic pay > Rs. 25000 then there is no change in basic pay.
  Write a function to print the details of employee who have completed 20 years of service from the date of joining.
Program:

#include<stdio.h>
#include<conio.h>
#include<math.h>
struct emp
{
     int eid;
     char ename[20];
     int basic;
     int day;
     int month;
     int year;
};
struct emp e[10];
int i;
void main()
{
     void empdetail();
     void basicpay();
     void display();
     clrscr();
     empdetail();
     basicpay();
     display();
     getch();
}
void empdetail()
{
     for(i=0;i<2;i++)
     {
        printf("\n enter id,name,basic,doj,enter day,month,year seperatly:");
        scanf("%d %s %d %d %d %d",&e[i].eid,&e[i].ename,&e[i].basic,&e[i].day,&e[i].month,&e[i].year);
     }
}
void basicpay()
{
     for(i=0;i<2;i++)
     {
        if(e[i].basic<=5000)
        e[i].basic=e[i].basic+((15*e[i].basic)/100);
        else if(e[i].basic>5000&&e[i].basic<=25000)
        e[i].basic=e[i].basic+((10*e[i].basic)/100);
        else
        e[i].basic=e[i].basic;
     }
}
void display()
{
     int year=2012;
     for(i=0;i<2;i++)
     {
         if((year-(e[i].year))>=20)
         printf("\nempid:%d\nname:%s\nsalary:%d\nday:%d\nmonth:%d\nyear:%d",
               e[i].eid,e[i].ename,e[i].basic,e[i].day,e[i].month,e[i].year);
     }
}
/*
INPUT:
enter id,name,basic,enter day,month,year seperatly of doj:
11       bittu       30000      13   04   1986

OUTPUT:

emp id:11
name:bittu
salary:30000
day:13
month:4
year:1986
*/

No comments:

Post a Comment