write a program to convert seconds into corresponding numbers of hours, min and seconds for example, 7266 second =2hrs, 1min,6sec
Answers
Answered by
1
Answer:
This program is written in c++ 14
#include<iostream>
using namespace std;
int main()
{
int s,rem;
int h=s/3600;
rem=s%3600;
int m=rem/60;
rem=rem%60;
cout<<h<<"hrs, "<<m<<"min,"<<rem<<"sec"<<endl;
return 0;
}
Answered by
5
Answer:
import java.util.Scanner;
public class SecondstoHrMinSec
{
public static void main(String[] args)
{
// create object of scanner class.
Scanner in = new Scanner(System.in);
// enter the seconds here.
System.out.print("Enter seconds : ");
int seconds = in.nextInt();
int p1 = seconds % 60;
int p2 = seconds / 60;
int p3 = p2 % 60;
p2 = p2 / 60;
System.out.print("HH:MM:SS - " +p2 + ":" + p3 + ":" + p1);
System.out.print("\n");
}
Similar questions
English,
4 months ago
Math,
4 months ago
Computer Science,
4 months ago
Computer Science,
9 months ago
Business Studies,
1 year ago