Toggle navigation
Courses
Questions
Tags
Users
04-06 Lab exercise 1: Structure to handle Time
0
like
0
dislike
811
views
Write a program with following requirements:
Define the
structure
type time with fields: hours, minutes, and seconds.
Write a function that takes an integer as parameter and converts that integer (as seconds) to hours, minutes, and seconds. These values should be stored into the fields of a structure of type time, and
the function should return that structure
.
Write a program that reads an integer, calls the function, and displays the fields of the returned structure.
Example input:
7776
Example output:
2:9:36
[Exercise]
Coding (C)
-
asked
Apr 6, 2017
in
C
ID: 23557 -
Available when:
Unlimited
-
Due to:
Unlimited
|
811
views
comment
0
0
Called for Help
Please
log in
or
register
to add a comment.
32
Answers
0
like
0
dislike
Hidden content!#include *** ** * * *
* *** * * * ** * * * **
struct Clock{
* * ** * *** * * *** * * * * hours;
* * ** * *** * *** minutes;
* * * ** * * ** *** * * * seconds;
};
int main(){
* *** * * * * ** **** * ** * input;
* * ** ** * *** ** * * ** * *** Clock * *
* ** * * * * ** * * * * ** ** * * * * * * *
**** ** * * ** * * * ***** ** * * = input / 3600;
* * * * * * * * **** ** * * * ** = (input % 3600) / 60;
* * * * ** * * * * * = (input % 3600) % 60;
* * * * ** * * **** ** * * **** * * ** * * ** * * * * * ** ** ** * * **
* * ** ** *** * * **** 0;
}
answered
May 17, 2017
by
Batman
(
-218
points)
ask related question
comment
Please
log in
or
register
to add a comment.
0
like
0
dislike
Hidden content!#include * * * *
*** * * * *** ** ****** *
struct Clock{