Monday, June 18, 2012

To display time with the help ofstructure data type


/* Program to display time with the help of structure data type */

#include<stdio.h>

#include<conio.h>

void main()

{

  struct time_struct

  {

    int hour;

    int min;

    int sec;

  }t;

  clrscr();

  printf("\nEnter hour:");

  scanf("%d",&t.hour);

  printf("\nEnter minutes:");

  scanf("%d",&t.min);

  printf("\nEnter seconds:");

  scanf("%d",&t.sec);

  printf("\n\nTime in given format:");

  printf("%d:%d:%d",t.hour,t.min,t.sec);

  getch();

}

 

OUTPUT

 

Enter hour:16

 

Enter minutes:40

 

Enter seconds:52

 

 

Time in given format:16:40:52

 

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.