C programming structure example with array
#include <stdio.h>#include <conio.h> #include <string.h> struct employee { char name[20]; int age; float salary; }; int main() { struct employee emp1, emp2, emp3; printf("Enter the name ,age and salary of the 3 employee\n"); printf("1st Employee :"); printf("\nName:"); scanf("%s", &emp1.name); printf("Age:"); scanf("%d", &emp1.age); printf("Salary:"); scanf("%f", &emp1.salary); printf("2nd Employee :"); printf("\nName:"); scanf("%s", &emp2.name); printf("Age:"); scanf("%d", &emp2.age); printf("Salary:"); scanf("%f", &emp2.salary); printf("3rd Employee :"); printf("\nName:"); scanf("%s", &emp3.name); printf("Age:"); scanf("%d", &emp3.age); printf("Salary:"); scanf("%f", &emp3.salary); printf("%s's age is %d and his salary is %.0f\n", emp1.name, emp1.age, emp1.salary); printf("%s's age is %d and his salary is %.0f\n", emp2.name, emp2.age, emp2.salary); printf("%s's age is %d and his salary is %.0f\n", emp3.name, emp3.age, emp3.salary); return 0; }
Output :
0 comments:
Post a Comment