# emp_inlab.c - Workshop...

• No School
• AA 1
• 3

This preview shows page 1 - 3 out of 3 pages.

// Workshop: 5 (in-lab) //============================================== #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> // Define Number of Employees "SIZE" to be 2 #define SIZE 2 // Declare Struct Employee struct employee { int number; int age; double salary; }; /* main program */ int main(void) { int option = 0; int i, j = 0; // Declare a struct Employee array "emp" with SIZE elements // and initialize all elements to zero struct employee emp[SIZE] = { { 0, 0, 0 } }; printf("---=== EMPLOYEE DATA ===---\n\n"); do { // Print the option list printf("1. Display Employee Information\n"); printf("2. Add Employee\n"); printf("0. Exit\n\n"); printf("Please select from the above options: "); // Capture input to option variable scanf("%d",&option); printf("\n"); switch (option) { case 0: // Exit the program printf("Exiting Employee Data Program. Good Bye!!!\n"); break; case 1: // Display Employee Data // @IN-LAB printf("EMP ID EMP AGE EMP SALARY\n"); printf("====== ======= ==========\n"); // Use "%6d%9d%11.2lf" formatting in a // printf statement to display // employee id, age and salary of // all employees using a loop construct for (i = 0; i < SIZE; i++) { if (emp[i].number > 0) { printf("%6d%9d%11.2lf\n", emp[i].number, emp[i].age,
emp[i].salary); } } printf("\n");

#### You've reached the end of your free preview.

Want to read all 3 pages?

• Fall '19

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern