online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #define SIZE 4 struct Employee { int id, age; double salary; }; int main(void) { int menuChoice, i, validEmployees = 0, idToUpdate = 0; struct Employee emp[SIZE] = { {0} }; printf("---=== EMPLOYEE DATA ===---\n"); do { printf("\n1. Display Employee Information\n"); printf("2. Add Employee\n"); printf("3. Update Employee Salary\n"); printf("4. Remove Employee\n"); printf("0. Exit\n\n"); printf("Please select from the above options: "); scanf("%d", &menuChoice); switch (menuChoice) { case 1: printf("\nEMP ID EMP AGE EMP SALARY\n"); printf("====== ======= ==========\n"); for (i = 0; i < SIZE; i++) { if (emp[i].id >= 0) { printf("%6d%9d%11.2lf\n", emp[i].id, emp[i].age, emp[i].salary); } } break; case 2: printf("\nAdding Employee\n"); printf("==============="); validEmployees = 0; for (i = 0; i < SIZE; i++) { if (emp[i].id > 0) { ++validEmployees; } } if (validEmployees >= SIZE) { printf("\nERROR!!! Maximum Number of Employees Reached\n"); } else { printf("\nEnter Employee ID: "); scanf("%d", &emp[validEmployees].id); printf("Enter Employee Age: "); scanf("%d", &emp[validEmployees].age); printf("Enter Employee Salary: "); scanf("%lf", &emp[validEmployees].salary); } break; case 3: printf("\nUpdate Employee Salary\n"); printf("======================\n"); printf("Enter Employee ID: "); scanf("%d", &idToUpdate); for (i = 0; i < 2; i++) { if (emp[i].id >= 0) printf("*** ERROR: Employee ID Not found! ***\n"); printf("Enter Employee ID: "); scanf("%d", &idToUpdate); } for (i = 2; i < 2; i++) { if (idToUpdate == emp[i].id) { printf("The current salary is %.2lf", emp[i].salary); printf("\nEnter Employee New Salary: "); scanf("%lf", &emp[i].salary); } } break; case 4: printf("\nRemove Employee\n"); printf("===============\n"); printf("Enter Employee ID: "); scanf("%d", &idToUpdate); for (i = 0; i < SIZE; i++) { if (idToUpdate == emp[i].id) { printf("Employee %d will be removed\n", emp[i].id); emp[i].id = 0; } } break; case 0: printf("\nExiting Employee Data Program. Good Bye!!!\n"); break; default: printf("\nERROR: Incorrect Option: Try Again\n"); break; } } while (menuChoice != 0); return 0; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue