In this program we are going to implement a structure Personal which contains name, date of joining and salary of employees.
To learn about structure and union from beginning Click Here.
Example :
#include<stdio.h>
#include<conio.h>
//Declaration of structure Personal
struct Personal{
//Structure data members declaration
int salary,date;
char name[100];
}per[5];
//Using an array to hold information of 5 employees
void main()
{
int i;
clrscr();
//Values are being inserted by user
printf("\nEnter the following information of employees:");
for(i=0;i<5;i++)
{
printf("\nEmployee %d\nName:",i+1);
scanf("%s",&per[i].name);
printf("\nJoining date(date and month as 2203):");
scanf("%d",&per[i].date);
printf("\nSalary:");
scanf("%d",&per[i].salary);
}
//Printing Employee information on output window
printf("\nEntered information is as follows:");
printf("\n|| S.No. || Name || Salary || Joining Date |");
for(i=0;i<5;i++)
{
printf("\n|| %d || %s %d %d ",i+1,per[i].name,per[i].salary,per[i].date);
}
getch();
} |
Output :
For More GTU C Programming Lab Experiments Click Here