Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* Pleasedontcode.com **********
- Pleasedontcode thanks you for automatic code generation! Enjoy your code!
- - Terms and Conditions:
- You have a non-exclusive, revocable, worldwide, royalty-free license
- for personal and commercial use. Attribution is optional; modifications
- are allowed, but you're responsible for code maintenance. We're not
- liable for any loss or damage. For full terms,
- please visit pleasedontcode.com/termsandconditions.
- - Project: "Employee Management"
- - Source Code NOT compiled for: Arduino Uno
- - Source Code created on: 2024-12-01 18:31:00
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* There is a structure called employee that holds */
- /* information like employee code, name, and date */
- /* of joining. Write a program to create an array */
- /* of structures and enter some data into it. Then */
- /* ask the user to enter current date. Display the */
- /* names */
- /****** END SYSTEM REQUIREMENTS *****/
- /* START CODE */
- /****** DEFINITION OF LIBRARIES *****/
- // No standard input/output libraries like <stdio.h> or <conio.h> are available in Arduino
- // #include<stdio.h>
- // #include<conio.h>
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- struct employee
- {
- int code;
- char name[30];
- int doj[3]; // Date of joining: day, month, year
- } hcl[50] = {
- {1, "Shahnawaz", {13, 1, 2006}},
- {4, "Amit Puri", {21, 6, 2008}},
- {102, "Irfan Moin", {12, 5, 2012}},
- {131, "Shabnam", {16, 1, 2014}}
- };
- // Function prototype for printinfo
- void printinfo(struct employee k);
- void setup(void)
- {
- // Initialize serial communication
- Serial.begin(9600);
- }
- void loop(void)
- {
- int d[3];
- // For demonstration, we will use a fixed date
- d[0] = 15; // day
- d[1] = 10; // month
- d[2] = 2023; // year
- Serial.println("\nEmployees with greater than or equal to 3 years of tenure\n");
- for (int i = 0; i < 4; i++)
- {
- if (d[2] - hcl[i].doj[2] > 3)
- printinfo(hcl[i]);
- else if (d[2] - hcl[i].doj[2] == 3)
- {
- if (d[1] - hcl[i].doj[1] > 0)
- printinfo(hcl[i]);
- else if (hcl[i].doj[1] == d[1])
- {
- if (d[0] - hcl[i].doj[0] >= 0)
- printinfo(hcl[i]);
- }
- }
- }
- // Add a delay to avoid flooding the serial output
- delay(10000); // Wait for 10 seconds before repeating
- }
- void printinfo(struct employee e)
- {
- Serial.print("\nCode : ");
- Serial.println(e.code);
- Serial.print("Name : ");
- Serial.println(e.name);
- Serial.print("Date of joining : ");
- Serial.print(e.doj[0]);
- Serial.print("-");
- Serial.print(e.doj[1]);
- Serial.print("-");
- Serial.println(e.doj[2]);
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement