Develop a C program to declare a structure which will contain the following data for 3 employees: Employee code (as character), Name (as character), and age (as integer). The employee codes to be stored in this structure are E01, E02 and E03.
Code
#include <stdio.h>/*structure declaration*/struct employee{char code[10];char name[30];int age};int main(){/*declare structure variable*/struct employee E01, E02, E03;/*read employee details*/printf("\nEnter details for E01 :\n");printf("Code ?:");scanf("%s",&E01.code);printf("Name ?:");scanf("%s",&E01.name);printf("Age ?:");scanf("%d", &E01.age);printf("\nEnter details for E02 :\n");printf("Code ?:");scanf("%s",&E02.code);printf("Name ?:");scanf("%s",&E02.name);printf("Age ?:");scanf("%d", &E02.age);printf("\nEnter details for E03 :\n");printf("Code ?:");scanf("%s",&E03.code);printf("Name ?:");scanf("%s",&E03.name);printf("Age ?:");scanf("%d", &E03.age);printf("\nDeailts of E01\n");printf("Code: %s\n",E01.code);printf("Name: %s\n",E01.name);printf("Age: %d\n",E01.age);printf("\nDeailts of E02\n");printf("Code: %s\n",E02.code);printf("Name: %s\n",E02.name);printf("Age: %d\n",E02.age);printf("\nDeailts of E03\n");printf("Code: %s\n",E03.code);printf("Name: %s\n",E03.name);printf("Age: %d\n",E03.age);return 0;}
Output
0 Comments
Post a Comment