Time using structure

Problem Statement
Write a c program to show use of structure
make a structure which is having 3 places 
  1. hour
  2. minute
  3. second
take input from user and then print in suitable format
#include<stdio.h>
struct time_struct{
  int hour;
  int minute;
  int sec;
};
int main()
{
  struct time_struct t1;
  int y;
  printf("enter hour \n");
  scanf("%d",&t1.hour);
  printf("enter minute \n");
  scanf("%d",&t1.minute);
  printf("enter secound \n");
  scanf("%d",&t1.sec);
  printf("the given time is \n %d:%d:%d",t1.hour,t1.minute,t1.sec);
  scanf("%d",&y);
  return 0;
}


No comments:

Post a Comment