bsc

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

pc017.c (1050B)


      1 /*
      2  * Author: Amit Dutta (amitdutta4255@gmail.com) | Date: 21 Apr 2026
      3  * Repo: https://github.com/notamitgamer/bsc
      4  * License: MIT
      5  */
      6 
      7 /* Write a program to calculate the difference between two time periods using structures. */
      8 
      9 #include <stdio.h>
     10 #include <stdlib.h>
     11 
     12 typedef struct time_reference
     13 {
     14     int hour;
     15     int min;
     16     int sec;
     17 } timeRef;
     18 
     19 int main()
     20 {
     21     timeRef a, b;
     22     long long int tSeconds_a, tSeconds_b, timeDiff;
     23 
     24     printf("== Note: Time should be entered in HH-MM-SS 24-hour clock format ==");
     25     printf("\nEnter the time reference a: ");
     26     scanf("%d-%d-%d", &a.hour, &a.min, &a.sec);
     27     printf("Enter the time reference b: ");
     28     scanf("%d-%d-%d", &b.hour, &b.min, &b.sec);
     29 
     30     tSeconds_a = (a.hour * 3600) + (a.min * 60) + a.sec;
     31     tSeconds_b = (b.hour * 3600) + (b.min * 60) + b.sec;
     32 
     33     timeDiff = tSeconds_a - tSeconds_b;
     34     timeDiff = abs(timeDiff);
     35 
     36     printf("\nTime Difference: %lld Hours, %lld Minutes, %lld Seconds.", timeDiff / 3600, (timeDiff % 3600) / 60, (timeDiff % 3600) % 60);
     37     return 0;
     38 }
© 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