sec to min to hour program

sec to min to hour in c

#include<stdio.h>
#include<conio.h>
void main()
{
	int totalsecond,hour,minute,second;
	printf("Enter total second \n");
	scanf("%d",&totalsecond);
	hour=totalsecond/3600;
	totalsecond%=3600;
	minute=totalsecond/60;
	second=totalsecond%60;
	printf("hour = %d , minute = %d ,second = %d ",hour,minute,second);
	getch();
}

Output

Enter total second
3672
hour = 1 , minute = 1 ,second = 12

sec to min to hour in c++

#include<iostream>
#include<conio.h>
using namespace std;
void main()
{
	int totalsecond,hour,minute,second;
	cout<<"Enter total second \n";
	cin>>totalsecond;
	hour=totalsecond/3600;
	totalsecond%=3600;
	minute=totalsecond/60;
	second=totalsecond%60;
	cout<<"hour = "<<hour<<" minute = "<<minute<<" second = "<<second;
	getch();
}

Output

Enter total second
4200
hour = 1 minute = 10 second = 0

sec to min to hour in c#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConvertTotalSecondToHourMinuteSecond
{
    class Program
    {
        static void Main(string[] args)
        {
            int totalsecond, hour, minute, second;
            Console.WriteLine("Enter total second");
            totalsecond = Convert.ToInt32(Console.ReadLine());
            hour = totalsecond / 3600;
            totalsecond %= 3600;
            minute = totalsecond / 60;
            second = totalsecond % 60;
            Console.WriteLine("hour = " +hour +" minute = " + minute + " second = " + second);
            Console.ReadLine();
        }
    }
}

Output

Enter total second
1234
hour = 0 minute = 20 second = 34

sec to min to hour in java

import java.util.*;
class examples
{
public static void main(String[] args)
	{
	Scanner sc=new Scanner(System.in);
	int totalsecond, hour, minute, second;
    System.out.println("Enter total second");
    totalsecond =sc.nextInt();
    hour = totalsecond / 3600;
    totalsecond %= 3600;
    minute = totalsecond / 60;
    second = totalsecond % 60;
    System.out.println("hour = " +hour +" minute = " + minute + " second = " + second);
	}
}

Output

Enter total second
3690
hour = 1 minute = 1 second = 30

Write a comment


Name Email Message