Home » Sometech » WAP to prepare salary chart of employee using array of structures.

WAP to prepare salary chart of employee using array of structures.

#include <stdio.h>

#define S 10

typedef struct

{

   int empl_no;

   char name[30];

   int attendance;

  float daily_wage;

  float salary;

}employee;

 

void linkfloat()

{

 float x=0,*y;

 y=&x;//cause the emulator to be linked

 x=*y;//supress warning – variable not used

}

void main(void)

{

 int i,n;

 employee emp[S]; //  array of structures

clrscr();

printf(“Enter total number of employees (<=%d)”,S);

scanf(“%d”,&n);

for(i=0;i<n;i++)

{

printf(“Enter the record for employee – %d\n”,i+1);

printf(“\nEmployee number : “);

scanf(“%d”,&emp[i].empl_no);

fflush(stdin);

printf(“Name : “);

gets(emp[i].name);

printf(“Attendance days: “);

scanf(“%d”,&emp[i].attendance);

printf(“Daily wage :”);

scanf(“%f”,&emp[i].daily_wage);

emp[i].salary=emp[i].attendance*emp[i].daily_wage;

 

 

 

}

/*print the data*/

printf(“\nEmployee No.       Name        Total Salary\n”);

for(i=0;i<n;i++)

printf(“%8d%20s%15.2f\n”,emp[i].empl_no,emp[i].name,emp[i].salary);

getch();

}

Advertisements

SoME Tech

Error: Twitter did not respond. Please wait a few minutes and refresh this page.

%d bloggers like this: