Computer Science, asked by dineshmishra50, 4 months ago

write a program to input the time in seconds. Diplay the time after converting them into hours, minutes and seconds.​

Answers

Answered by Haruhi22
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