0 like 0 dislike
4.5k 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 in C
ID: 23557 - Available when: Unlimited - Due to: Unlimited
| 4.5k views
0 0
Called for Help

32 Answers

0 like 0 dislike
Hidden content!
** * * * * *
* ** * *** *
* * * ** * ***

int main(){




* time {
***** * * * ***** ** * hour;
** * * ** ***** ** ** min;
* ** * ** * * * ** sec;

} time;

int num;
*** *** * ** ** ** ******
** * = *** *
*** = * * *******
** ** = ******** ** **

printf * * * * * *** * * ** **** ** ** *







return 0;

}
answered by (-136 points)
0 like 0 dislike
Hidden content!
#include * * **



struct DN{
******** * * * ********* hours;
* * ** * *** * * * minutes;
* ** ** ** * * * * ** seconds;

};



struct DN DNIB ( struct DN N ){
* * *** **** ** ***** = **
** * **** ** **** ** * = * *
***** *** *** *** * * %= 60;
** * **** **** * ** * ** **** * %= 60;


* * * ** * ** N;

}



int main(int argc, char* argv[]){
* *** ** *** ** ** * * DN D;
* ** ** *** * ** ** ** * * * * * ** ** * ****
* * * * * * **** * *
** * * * ** **** ** ** * * * * * ** * ** * D.hours, ** **
***** * ** * ** * * 0;

}
answered by (-581 points)
0 like 0 dislike
Hidden content!
*** ** * * * * *
* **** ****** * **


** *** struct Time{
*** * * * * int h;
* ***** int m;
* * * * ** int s;
***



int *
* * * ** ** int input;
** * ** ** * time a;
* ** * * * *** ** * * ** *** * * ** ****
** *** * ** ** ** * * a.h = * * ***
**** * * * ** ** ** a.m = * **** **
***** *** **** * * *** * * a.s = *****
* * * ** * * * * ** * * ** ********** ** ** *
* * **** }
* **** ** * *** return 0;

}
answered by (24 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>

#include <stdlib.h>



typedef struct Time{
* * * **** * ******* ** *** h;
* * *** ****** * * * * * m;
** * * **** ** * *** s;

};



int main(){
* * ** * *** * **** input;
* * * ** ** * * * * * time;
**** * **** * * * ***** ********* * * ****** * *
*** * ***** ** ** * ** *** ** * * **** * = (input/60)/60;
***** * * *** * * * ******* ** * *** * * * ** ** = (input/60)%60;
* * ** ** *** ** ***** ** *** * **** ** ** = input%60;
* * **** **** ***** * *** ** * *** * ** * ** ***** **** ** * ** * ** * ** *
* **** **** ***** *
***** * ** * * *** ** * * 0;

}
answered by (24 points)
0 like 0 dislike
Hidden content!
* * ***** ***
* * ** * * ** * *


** * * * time{
* * * **** int hour;
* ** * * * int **
** ** *** int *
* * *


***** * * ** , int );
* * ***

int **
**** * *

* * ** * int
** ** * ** * ** **** * t = **
** * * *** * ** * ** **** ** * * * *****

** * **** t = ** ** *
* * ** * * ** * ** ** *** * ***** * * ** ** ******
* ** * * * * * * 0;

}
***** * * **
** * * ** * ptr = ** **** * * * ***
* ** * * * **** * * = 0;
*** * * ** * *** = 0;
** *** ** * *** ** = 0;
* ** ****

* ** *** ** * ptr;

}
* ** * * ** * * t, int
* * ** **** int temp = input / 3600;
* *** * int tem = * - ****
* * * * * int final = input - * - *** ;
* * ** * ** * ** = temp;
* * * ** * ** **** * = tem;
* ***** **** * ** ** = *****
* ** ***** * * t;

}
answered by (-134 points)
0 like 0 dislike
Hidden content!
#include<stdio.h>

#include<stdlib.h>

int main()

{
**** ** * *** * ** ** * sec=0,hour=0,min=0;
** * * ** ** ******* * total;
**** ******** *** * * * * * *** * ** * * ** ** *
** * ** *** * ** *** * * * *** *
* ***** * *** ** * ** *** * * ***
* * ** * * * ** * * * * *
***** * * **** * * ******* ** *** ** **** *** *** **
** *** * * ** * 0;

}
answered by (-384 points)
0 0
Your answer is not accepted, please follow the requirements and upload another answer.
0 like 0 dislike
Hidden content!
#include <stdio.h>

#include <string.h>

int main(void)

{
******** * ** * * *

    {
* ******** * * * ***** *** *** ** * hour;
***** ** **** ** *** * ** **** * ** * minute;
* * * *** * * * * ** ** * * * ** * * * second;
***** * * ** * *** ** * ** * ;


* ** * *** *** * bn,i,j;
* * *** *** ** ** *** *** * ******* ** * *** **


*** * * ** **** ***** **** * * * *

    {
* *** * ** * ***** * ***** ****** **** ** * * ** *
** ** **** *** * * * ***** * * ** * ** **


**** * * ******** ****** * * * ** * * * * * ** * **
**** ** **** ** * * ** * * * *** * ***** * * *** ***


* ** *** * * ** **** *** *** **** * *******

    }
* * *** ** * * * *** * * *** *** ** * * ** *** * * * ***

    {
*** ** * * * * * * * **** * * ***** * * * *
* * *** ** **** ** * * * * * ** ****** * ** *


*** **** * * * * * * ** *** * ***** * * * ** ** *
* * * * **** *** ****
* * **** ** **** * * **** * ** * ** * * ** * **

    {
** ***** * ** * * **** * ** * *** * *** * *** *** *** ***

    }


**** * * ********** **** **** * ** *** ** * ** ***** *** ** * * * ** *

}
answered by (-324 points)
0 like 0 dislike
Hidden content!
#include<stdio.h>

int main ()

{
*** * **** a,b,c,d,e;
* ***** ** ** ** * * * ** **** * **** ******** * *
** *** ** ** * ****** ***
* ** **** *
***** * ** ****
* * *** ** * * * ** * * *** *
* **** ** ** ** *** * *** ** *** * ** * * *

}
answered by (-249 points)
0 0
Your answer is not accepted, please follow the requirements and upload another answer.
0 like 0 dislike
Hidden content!
#include * * ** *

#include * ** *



typedef struct

{
*** * ** ** * ***** hours;
* * * ** ** *** ***** minutes;
* *** ** ** **** ** * ** seconds;



}time;

time input();

int main(void)

{
* ** * * ** ** ** * **** ** NULL, _IONBF, 0);
* * * ** ** *** ** * * ** **** * NULL, _IONBF, 0);
* **** * * * * sol;
** *** * * ****** * *** * * **
* ***** * * ***** * ** ** * * **** * **** * *
***** *** ** **** * EXIT_SUCCESS;

}

time input()

{
** ** ** ** **** ** * **** sol;
* * ** ** * * ***** ** in;
**** * *** *** *** ** * ** ** ** * * **** *
* *** ** ** * *** **** ** ** *
* * * **** * * *** *** * * ****
*** ** ** * * ** * ****** * *** * *
** ** * ** *** ******* **** sol;

};
answered by (0 points)
0 like 0 dislike
Hidden content!
#include ** * * *
* * ** *** ***



struct Time{
** ** *** * * * * ** * hours;
**** * * ** ** * * ** minutes;
* * ** * * * ** * *** * seconds;

};



struct Time conv(int n)

{
** ** * **** * * * ******* Time t;
** *** ** ** * * * * * *** = n/3600;
**** *** * *** **** * = ** *** **
* *** ** * ** **** * **** = * **** *


* *** * * ** * * **** t;

}



int main()

{
** ** * * * *** * * * n;
* ** ****** *** ** ** * * ** **** *
** * * * * * * ** * **** Time t = conv(n);
* ** ** ******* ** ** * * * * ** *** t.hours, ** *** * * * *


** **** **** * **** 0;

}
answered by (5.2k points)
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:108.162.216.240
©2016-2025

Related questions

0 like 0 dislike
64 answers
[Exercise] Coding (C) - asked Apr 6, 2017 in C
ID: 23560 - Available when: Unlimited - Due to: Unlimited
| 7.9k views
0 like 0 dislike
18 answers
[Exercise] Essay (Open question) - asked Apr 20, 2017 in C
ID: 24219 - Available when: Unlimited - Due to: Unlimited
| 3.4k views
12,783 questions
183,442 answers
172,219 comments
4,824 users