Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

8bitbubsy Nov 26th, 2018 (edited) 108 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. #include <stdio.h>  /* printf() */
  2. #include <stdlib.h> /* system() */
  3. #include <stdint.h>
  4.  
  5. char *_24hrToAmPm(int8_t hr)
  6. {
  7.     if (hr < 12)
  8.         return "AM";
  9.     else
  10.         return "PM";
  11. }
  12.  
  13. int8_t _24hrTo12hr(int8_t hr)
  14. {
  15.     hr %= 12;
  16.  
  17.     if (hr == 0)
  18.         return 12;
  19.     else
  20.         return hr;
  21. }
  22.  
  23. int main(int argc, char* argv[])
  24. {
  25.     int8_t hr;
  26.  
  27.     for (hr = 0; hr < 24; ++hr)
  28.         printf("%02d, %02d%s\n", hr, _24hrTo12hr(hr), _24hrToAmPm(hr));
  29.  
  30.     system("PAUSE");
  31.     return (0);
  32. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top