Advertisement
Guest User

Untitled

a guest
Jan 26th, 2020
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. //1
  6. /*
  7. typedef struct {
  8. int id;
  9. char name[20];
  10.  
  11. }Opt1;
  12.  
  13. struct Opt2 {
  14. int id;
  15. char name[20];
  16. };
  17.  
  18.  
  19. //2
  20.  
  21. struct date {
  22. int day, month, year;
  23. };
  24.  
  25. typedef struct {
  26. int day;
  27. int month;
  28. int year;
  29. }date;
  30.  
  31. struct date {
  32. int day, month, year;
  33. }birthday;
  34. birthday = {10, 10, 2010};
  35.  
  36. //3
  37. struct time
  38. {
  39. int hour, minute, seconds;
  40. };
  41. */
  42.  
  43. void question3()
  44. {
  45. typedef struct{
  46. int hour, minute, seconds;
  47.  
  48. }time;
  49.  
  50.  
  51. time t[2] , t3;
  52. for (int i = 0; i < 2; i++)
  53. {
  54. fprintf(stdin, "Enter Hour:");
  55. fscanf(stdin, "%d", &t[i].hour);
  56. fprintf(stdin, "Enter minute:");
  57. fscanf(stdin, "%d", &t[i].minute);
  58. fprintf(stdin, "Enter Seconds:");
  59. fscanf(stdin, "%d", &t[i].seconds);
  60.  
  61. }
  62. t3.hour = t[0].hour - t[1].hour;
  63. t3.minute = t[0].minute - t[1].minute;
  64. t3.seconds = t[0].seconds - t[1].seconds;
  65.  
  66. printf(" delta time is: %d %d %d", t3.hour, t3.minute, t3.seconds);
  67.  
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement