Define a structure data type called time_struct containing three member’s integer hours, minutes, second. Develop a program that would assign values to individual member and display the time in following format : HH:MM:SS

Question: Define a structure data type called time_struct containing three member’s integer hours, minutes, second. Develop a program that would assign values to individual member and display the time in following format: HH:MM:SS.

Define a structure data type called time_struct containing three member’s integer hours, minutes, second. Develop a program that would assign values to individual member and display the time in following format : HH:MM:SS


  1. /*
  2. 51. Define structure data type called time_struct containing three member’s integer hour, integer minute and integer second. Develop a program that would assign values to the individual number and display the time in the following format: 16: 40:51 
  3. */

  4. #include <stdio.h>

  5. struct time_struct
  6. {
  7.  int hour;
  8.  int minute;
  9.  int second;
  10. }t;

  11. int main(void) 
  12. {
  13.  printf("\n Enter Hour : ");
  14.  scanf("%d",&t.hour);
  15.  printf("\n Enter Minute: ");
  16.  scanf("%d",&t.minute);
  17.  printf("\n Enter Second : ");
  18.  scanf("%d",&t.second);

  19.  printf("\n Time %d:%d:%d",t.hour%24,t.minute%60,t.second%60);
  20.  
  21.  return 0;
  22. }

Output:
Define a structure data type called time_struct containing three member’s integer hours, minutes, second. Develop a program that would assign values to individual member and display the time in following format: HH:MM:SS

Download the Android app to get all Government Job Notifications on your Mobile.
Download Now
Important: Please always Check and Confirm the above details with the official Advertisement / Notification.
Previous Post Next Post