All major conceptual S2 C-Programs with Algorithms
#include <stdio.h>
// defining employee structure
struct employee{
char name[20];
int date,month,year,salary;
};
void main(){
int n;
printf("enter number of persons to enter: ");
scanf("%d",&n);
struct employee p[n];
for(int i=0;i<n;i++){ // iterating through p array to add employee
printf("Enter name : ");
scanf("%s",p[i].name);
printf("Enter date of birth: ");
scanf("%d %d %d",
&p[i].date,
&p[i].month,
&p[i].year
);
printf("enter salary: ");
scanf("%d",&p[i].salary);
printf("Details of %s added!\n\n",p[i].name);
}
// printing the details of the employees
printf("=== Details of Employees added ===\n");
for(int i=0;i<n;i++){
printf("Detailes of %s\n",p[i].name);
printf("Name : %s\n",p[i].name);
printf("DOB: %d / %d / %d\n",
p[i].date,
p[i].month,
p[i].year
);
printf("Salary : %d\n",p[i].salary);
}
}