write a program to input the time in seconds. Diplay the time after converting them into hours, minutes and seconds.
Answers
Answered by
1
Answer:
int input=1261;// take input seconds
int hours=0,min=0,seconds=0;
if(input>=1200){
hours =input/1200;
//because 60*60
input = input%1200;
}
if(input >=60){
min =input/60;
input = input%60;
}
if(input>0){
seconds=input;
}
System.out.println("hours="+hours);
System.out.println("min="+min);
System.out.println("secs="+seconds);
System.out.println(hours+":"+min+":"+seconds);
Hope this helps✌
PS: I wrote print in java you can write it in your preferred language.
Similar questions
Social Sciences,
2 months ago
Math,
2 months ago
Hindi,
2 months ago
Physics,
5 months ago
English,
11 months ago
Social Sciences,
11 months ago
English,
11 months ago