bsc

Comprehensive codebase and cou...
Log | Files | Refs | README | LICENSE

luc082.c (1542B)


      1 /*
      2  * Author  : Amit Dutta <amitdutta4255@gmail.com>
      3  * Date    : 08 Feb 2026
      4  * Repo    : https://github.com/notamitgamer/bsc
      5  * License : MIT License (See the LICENSE file for details)
      6  */
      7 
      8 /* Structure 'employee' (Code, Name, Date of Joining). Display names of employees with tenure >= 3 years.
      9 */
     10 /* Let Us C, Chap- 17 (Structures), Qn No.: B(e) */
     11 
     12 /* This file is auto-generated by a bot. */
     13 /* This code is not compiled; it is for reference only. */
     14 
     15 
     16 #include <stdio.h>
     17 #include <string.h>
     18 #include <stdlib.h>
     19 
     20 struct date
     21 {
     22     int day;
     23     int month;
     24     int year;
     25 };
     26 
     27 struct employee
     28 {
     29     int code;
     30     char name[30];
     31     struct date doj;
     32 };
     33 
     34 int main()
     35 {
     36     struct employee emp[5] = {
     37         {101, "Amit", {12, 1, 2020}},
     38         {102, "Sumit", {15, 8, 2023}},
     39         {103, "Rina", {1, 1, 2018}},
     40         {104, "Tina", {20, 5, 2022}},
     41         {105, "Mina", {10, 12, 2025}}
     42     };
     43     int n = 5, i;
     44     struct date current;
     45 
     46     printf("Enter current date (dd mm yyyy): ");
     47     scanf("%d %d %d", &current.day, &current.month, &current.year);
     48 
     49     printf("\nEmployees with tenure >= 3 years:\n");
     50     for (i = 0; i < n; i++)
     51     {
     52         int years = current.year - emp[i].doj.year;
     53         
     54         // Adjust for month/day
     55         if (current.month < emp[i].doj.month || 
     56            (current.month == emp[i].doj.month && current.day < emp[i].doj.day))
     57         {
     58             years--;
     59         }
     60 
     61         if (years >= 3)
     62         {
     63             printf("%s (Tenure: %d years)\n", emp[i].name, years);
     64         }
     65     }
     66 
     67     return 0;
     68 }
© notamitgamer • Site Built: 2026-07-21 13:58:23 UTC • git-mirror commit: 1037f62 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror