Write a program to create a structure employee with empno, name and salary, accept and display the details, create an array of structures of fixed size.

/* Write a program to create a structure employee with empno, name and salary,

accept and display the details, create an array of structures of fixed size.*/

#include <stdio.h>

 

struct employee

{

    int empno;

    char empname[20];

    float sal;

}e[3];

void main()

{

    int i;

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

    {

        printf("Employee %d:\n",i+1);

        printf("Enter the employee number : ");

        scanf("%d",&e[i].empno);

        fflush(stdin);

        printf("Enter the employee name   : ");

        gets(e[i].empname);

        printf("Enter the employee salary : ");

        scanf("%f",&e[i].sal);

    }

    printf("--------------------------------------------------------------\n");

    printf("   Empno      Employee Name              Salary\n");

    printf("--------------------------------------------------------------\n");

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

    {

        printf("  %5d    %-26s    %7.2f\n",e[i].empno,e[i].empname,e[i].sal);

    }

    printf("--------------------------------------------------------------\n");

    getch();

}

Comments

Popular posts from this blog

Write a program to accept numerator and denominator and find the remainder without using modulus (%) operator using do..while loop.