Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * to input the name and salary of 5 employees using structure and display in
- * proper format:
- */
- #include <stdio.h>
- void getData(), putData();
- struct employeeData
- {
- int salary;
- char name[50];
- };
- struct employeeData employee[5];
- int i;
- void main()
- {
- getData();
- putData();
- }
- void getData()
- {
- printf("Please enter the name and respective salary of 5 different employees.\n");
- for(i=0;i<5;i++)
- {
- printf("\n \n Name: ");
- fgets(employee[i].name,50,stdin);
- printf("\n Salary: ");
- scanf("%d", &employee[i].salary);
- }
- }
- void putData()
- {
- printf("\n\n The following information was gathered:\n");
- printf("NAME \t\t\t\t\t SALARY \n");
- for(i=0;i<5;i++)
- {
- printf("%s \t\t\t\t\t %d \n", employee[i].name, employee[i].salary);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement