Toggle navigation
Courses
Questions
Tags
Users
04-06 Lab exercise 1: Structure to handle Time
0
like
0
dislike
2.7k
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
|
2.7k
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<stdio.h>
#include<string.h>
int main()
{
* ** * * * * *** * ** n;
* ** * * ** ** * *** *********** &n);
** * * ** * ***** ** * time{
* *** * *** * * *** ** * * * ** * *** * *** ** total;
* ** * * * *** * ** * ** *** *** * * ** * ** hrs;
* * ** * *** *** ** * * ** ***** * **** ** *** mins;
* ***** * ** * * ** * * * * * * * * * secs;
* * ** * * * * *** * * * *** n/3600, n/60-(part.hrs*60), ** ***** * * *** * **
*** *** * * ** * ** * ** * * * *** *** *** * ** * * * ***
}
answered
Apr 12, 2017
by
TheCupCakeMan
(
-368
points)
ask related question
comment
Please
log in
or
register
to add a comment.
0
like
0
dislike
Hidden content!
#include * * * * ****
#include ** * *** ** ** *
struct Clock{
* * * * * * * ** * *** ** hours;
* ***** ** * * * * * * * * minutes;
* ***** ** ** ** * * * seconds;
};
int main(){
* ** ** ***** ** * input;
** ** * * * **** ** * Clock MyClock;
* ** * * ** * *** * * * * * **** **
* ** *** *** * ****
* ***** * * ** ****** * * * = input / 3600;
* *** * *** ** *** * ***** **** * = (input % 3600) / 60;
*** *** * *** ** * ** * ** = (input % 3600) % 60;
** * *** * * ** * * *
* * * **** * **** * * ** * ****** * * **** * * * ** * * *** ***
** * ** * ** * * * * ** ****** 0;
}
answered
Apr 12, 2017
by
gmac2
(
-215
points)
ask related question
comment
Please
log in
or
register
to add a comment.
0
like
0
dislike
Hidden content!
#include * * * * * ******
#include ** ** ****
struct Clock{
* *** ***** ** * * *** hours;
* ******** * * ****** ** * minutes;
*** ** * ** * *** * * seconds;
};
int main(){
**** * * ***** * **** input;
* * ** ** ** Clock MyClock;
* ****** **** ** *** ** * ** ** *** ** ***
* ** * * ** ****
* * * * * * * * * * * = input / 3600;
* * * ** ** * * ** * **** * = (input % 3600) / 60;
** * * *** * ***** ** = (input % 3600) % 60;
* * * * * * ** * * *
** * ** * * ** * *** * ******** * ** ** ** ** *** ***
** ***** ******* *** * ** 0;
}
answered
Apr 6, 2017
by
Kevin52
(
-188
points)
ask related question
comment
Please
log in
or
register
to add a comment.
0
like
0
dislike
Hidden content!
** * * * ** *** **
int main ()
{
* ***
int min;
* **
*** *
int n;
* * * ** **** ** ** **** *
* *** **
* ** ** ** ** *
* * ***** * ** * * ** *****
*** ******* ** ** * **** **** ***
* * 0;}
answered
Apr 6, 2017
by
emgy1995
(
-34
points)
ask related question
comment
Please
log in
or
register
to add a comment.
0
like
0
dislike
Hidden content!
* **** **** ** ** **
* * ** **** ** *
* time{
int hour;
int min;
int sec;
};
int * ** *
int a;
* * **** * * * ** *
* *** * * * * ** * time h = **** *
* * * ** ** * * **** = ** ** * * * *
* ** *** * * * *** ****** * * ** * ** *** *
** ** * *** ** * ** * * time m = * **** * * ** *
* * * * * * ** * * ** time s = {.sec= * *** * * * ** ***
** *** **** ** **** * * ** * * ** ** *** *****
}
answered
Apr 6, 2017
by
agsrules99
(
-368
points)
ask related question
comment
Please
log in
or
register
to add a comment.
0
like
0
dislike
Hidden content!
#include ** ** **
** ** ** * ** *
int main()
{
*** * ** *** * * ** ** * a, s, m, h;
********* * **** * * * ***** ******* *
** *** * * * *** ** = a % 60;
* ** * ** * *** ** *** = (a/60) % 60;
** * * ******* * * ***** = * % 60;
*** * ** ***** * *** * * * * * h, m, s);
** * * **** * * *** 0;
}
answered
Apr 6, 2017
by
林欣儀
(
-364
points)
ask related question
comment
Please
log in
or
register
to add a comment.
0
like
0
dislike
Hidden content!
* * *** * * ****
struct time
{
* ***** ****** ** * ** ** ** hours;
* ** * * *** ** * * * ** minutes;
* * *** ****** ** *** seconds;
};
int main()
{
* ** * ** * * *** * * * t;
****** * ******** * *** ** * * ** * *** **
* * *** *** ** ** ** time t1;
* ** * * ** * * * *** * = t/3600;
* ** *** * *** * * * * = t%3600/60;
**** * * * * * * * * = t%3600%60;
* * ** ** * *** ** * *** ** * * * ***** * *** * *** * **
}
answered
Apr 6, 2017
by
chenching
(
-226
points)
ask related question
comment
Please
log in
or
register
to add a comment.
0
like
0
dislike
Hidden content!
#include<stdio.h>
int main ()
{
******** * * ** **** * * * a,b,c,d,e;
** *** * ** ** * * **** ** ** * ** ***
* * * * ** * * * *
** * ***** * * **** * ******
* * * * * * * * * * * *
* ** * * ****** * *** ** *
* *** ** ** * ** ** * *** *** ** ** * * *** * * *
}
answered
Apr 6, 2017
by
s22342710
(
-249
points)
ask related question
comment
Please
log in
or
register
to add a comment.
0
like
0
dislike
Hidden content!
#include<stdio.h>
#include<stdlib.h>
int main()
{
*** ** * * sec=0,hour=0,min=0;
*** ** ********* ** * ** * total;
* * *** ** *** ** ** * ****** * * * * ** **
* ** ** * **** * ******
* * ** ***** * * * **
** * * * * ** ** * * * ** **
********** ** * * * ** ***** ** * ** ** ** *
* * ** * * ** **** ***** * * 0;
}
answered
Apr 6, 2017
by
410511206
(
-384
points)
ask related question
comment
Please
log in
or
register
to add a comment.
0
like
0
dislike
Hidden content!
#include <stdio.h>
struct{
* ** * **** ** **** ** * hr;
* ** ** * * ** * min;
** **** * * * * ** * * ** * sec;
}time;
void calc(int s){
* ** * * ** **** ***** ** >= 3600)
* ** * * *** *** * **
** ** * **** * * * ** * * * *** * * * ** * * *** * = s/3600;
* * **** ** ***** ***** **** ** *** *** = s-(3600*time.hr);
}
********** * * *** >= 60)
* ** * ** *** ** * * ***
* * *** * * * * ** ** * * * * * * * * ** = s/60;
** * * ** ** **** *** ** * **** * *** = s-(60*time.min);
** * * * ** * **
** * * * * * * < 60)
* * * * * * * ***
*** **** * *** * ** * *** * ** **** ** *** ** * = s;
* ** ** ***** **** *****
** ** * * *** * * ** ** * ** * * * * * ** * * * * ******
}
int main()
{
** ** *** ** ** * * s;
****** * * **** ** ** * ** **** * **
** * ** * ***** * * * * * *
* * ** * * ** * ****** 0;
}
answered
Apr 6, 2017
by
isaias
(
-189
points)
ask related question
comment
Please
log in
or
register
to add a comment.
Page:
« prev
1
2
3
4
next »
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English
中文
Tiếng Việt
IP:172.69.58.151
©2016-2025
Related questions
0
like
0
dislike
64
answers
04-06 Lab exercise 2: Structure to handle StudentList
[Exercise]
Coding (C)
-
asked
Apr 6, 2017
in
C
ID: 23560 -
Available when:
Unlimited
-
Due to:
Unlimited
|
4.7k
views
0
like
0
dislike
18
answers
04-20 Lab Exercise: Read and write data to file
[Exercise]
Essay (Open question)
-
asked
Apr 20, 2017
in
C
ID: 24219 -
Available when:
Unlimited
-
Due to:
Unlimited
|
2k
views
12,783
questions
183,442
answers
172,219
comments
4,824
users