Modify the previous program such that a function is used to input values to the members and another function to display the time.
#include <stdio.h>
input();
void output(struct time_struct t);
struct time_struct
{
int hour;
int minute;
int second;
};
void main()
{
struct time_struct time;
clrscr();
printf("Enter hour:");
time.hour=input();
printf("Enter minute:");
time.minute=input();
printf("Enter seconds:");
time.second=input();
output(time);
getch();
}
input()
{
int a;
scanf("%d",&a);
return(a);
}
void output(struct time_struct t)
{
printf("%d:%d:%d",t.hour,t.minute,t.second);
}
OUTPUT
Enter hour: 16
Enter minute: 40
Enter seconds: 51
16:40:51
#include <stdio.h>
input();
void output(struct time_struct t);
struct time_struct
{
int hour;
int minute;
int second;
};
void main()
{
struct time_struct time;
clrscr();
printf("Enter hour:");
time.hour=input();
printf("Enter minute:");
time.minute=input();
printf("Enter seconds:");
time.second=input();
output(time);
getch();
}
input()
{
int a;
scanf("%d",&a);
return(a);
}
void output(struct time_struct t)
{
printf("%d:%d:%d",t.hour,t.minute,t.second);
}
OUTPUT
Enter hour: 16
Enter minute: 40
Enter seconds: 51
16:40:51
No comments:
Post a Comment