Tuesday, March 22, 2011

Structure and Unions

Define a structure data type called time_struct containing three members integer hour, integer minute and integer second. Develop a program that would assign values to the individual members and display the time in the following from:
16:40:51
#include <stdio.h>
struct time_struct
{
int hour;
int minute;
int second;
};
void main()
{
struct time_struct time;
clrscr();
time.hour=16;
time.minute=40;
time.second=51;
printf("%d:%d:%d",time.hour,time.minute,time.second);
getch();
}
OUTPUT
16:40:51

3 comments: