Skip to content

Convert Minutes To Days

Updated: at 02:54 PM

Table of contents

Open Table of contents

Write a program to convert minutes to days

1 day = 24 hours = 1440 minutes

Input  : 7200
Output : 5

C

// Write a C program to convert minutes to days

#include <stdio.h>

int main()
{
    int minutes;
    printf("Enter Minutes   :   ");
    scanf("%i", &minutes);

    int days = minutes / 1440;

    printf("Days    :   %i", days);
    return 0;
}

C#

// Write a C# program to convert minutes to days

using System;

class MainClass {
    public static void Main (string[] args) {
    Console.WriteLine ("Please enter the minutes :");
    double mins = Convert.ToDouble(Console.ReadLine());
    double days = mins / 1440;
    Console.WriteLine(mins + " minutes is "+ days + " days");
  }
}

C++

// Write a C++ program to convert minutes to days

/****************************************************************************
*	Project:	ConvertMinutesToDays						                *
*	File:		ConvertMinutesToDays.cpp           					       	*
*	Date: 		2023-01-31									        		*
*	Version: 	1.00														*
****************************************************************************/

#include <iostream>

/****************************************************************************/
int ConvertMinutesToDays(int min);
/****************************************************************************/
int main()
{
    int minutes = 0;

    std::cout << "Enter num of minutes\n";

    std::cin >> minutes;

    std::cout << ConvertMinutesToDays(minutes);

    return 0;
}
/****************************************************************************/
int ConvertMinutesToDays(int min)
{
    //1440 minutes in a day
    return min / 1440;
}
/****************************************************************************/

Dart

// Write a Dart program to convert minutes to days

import 'dart:io';
void main(){
  print("Enter the minutes :");
  var minutes =int.parse(stdin.readLineSync());
  var days = minutes/1440;
  print('Equivalent days : $days');
}

F#

// Write a F# program to convert minutes to days

let minutesToDays mins : int =
   mins / 1440

let days = minutesToDays 7200

printfn "Equivalent days : %d" days

Go

// Write a Go program to convert minutes to days

package main

import ("fmt")

func minutesToDays(i int) int {
	return (i / 24 / 60)
}

func main() {
	fmt.Println("Input Minutes: ")
	var i int
	fmt.Scanln(&i)
	fmt.Printf("%d minutes = %d days \n", i, minutesToDays(i))
}

Haskell

-- Write a Haskell program to convert minutes to days

main :: IO ()
main = do
   putStrLn "Enter minutes: "
   input1 <- getLine
   let minutes = read input1 :: Float

   let days = minutes / 1440
   putStrLn $ show (days)

Java

// Write a Java program to convert minutes to days

import java.util.Scanner;
class ConvertMinutes2Days {
  public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    System.out.print("Enter minutes: ");
    int minutes = input.nextInt();
    input.close();
    int days = minutes/1440;
    System.out.print("No of days: " + days);
  }
}

JavaScript

// Write a JavaScript program to convert minutes to days

/**
 *
 * @name This program converts minutes to days
 * @param {number} minutes
 * @returns {number} days
 *
 */

function ConvertMinutesToDays(minutes) {
  return minutes / 24 / 60;
}

// Console Tests
console.log(
  "How many days is 7,200 minutes? " + ConvertMinutesToDays(7200) + " days"
);
console.log(
  "How many days is 21,600 minutes? " + ConvertMinutesToDays(21600) + " days"
);
console.log(
  "How many days is 525,600 minutes? " + ConvertMinutesToDays(525600) + " days"
);

Julia

# Write a Julia program to convert minutes to days

println("Enter value in minutes: ")
minutes = readline()
minutes = parse(Int, minutes)
days = convert(Int, minutes / 1440)
println(minutes, " minutes equals ", days, " days")

Kotlin

// Write a Kotlin program to convert minutes to days

import java.util.Scanner

fun main() {
    val input = Scanner(System.`in`)
    print("Enter minutes: ")
    val minutes = input.nextInt()
    val days = minutes/1440;
    print("No of days:"+days)
}

Perl

# Write a Perl program to convert minutes to days

my $minutes = <STDIN>;
$days = $minutes / 1440;
print "days: $days"

PHP

// Write a PHP program to convert minutes to days

<?php
$x = readline('Enter Minutes: ');

$x1 = $x/1440;
echo "Days: $x1 \n";

?>

Python

# Write a Python program to convert minutes to days

def ConvertSectoDay(n):
    seconds = n * 60

    days = seconds // (24 * 3600)

    print(days)


n = int(input())
ConvertSectoDay(n)

R

# Write a R program to convert minutes to days

minutes = 7200
days = minutes / 1440
cat("days: ", days)

Ruby

# Write a Ruby program to convert minutes to days

#Function to convert minutes to days
def minutes_to_days(minutes)
    days = minutes / 1440
    return days
end

#Asks for user input
puts "Enter the number of minutes: "
minutes = gets.chomp.to_f

#Calls function to convert the user input
converted_days = minutes_to_days(minutes)
#Prints the input and output
puts "Input: #{minutes}"
puts "Output: #{converted_days}"

Rust

// Write a Rust program to convert minutes to days

use std::io;

fn main() {
    println!("Enter the number of minutes:");
    let mut input = String::new();
    io::stdin()
        .read_line(&mut input)
        .expect("Failed to read input.");

    let minutes: u32 = match input.trim().parse() {
        Ok(num) => num,
        Err(_) => {
            println!("Invalid input. Please enter a valid number of minutes.");
            return;
        }
    };

    let days = minutes / 1440;

    println!("{} minutes is equal to {} days.", minutes, days);
}

Scala

// Write a Scala program to convert minutes to days

import scala.io.StdIn._;

object minutesToDays {
  def main(args:Array[String]):Unit={
    println("Enter the minutes : ");
    var minutes = readLine();
    var days = minutes.toInt / 1440;
    println(minutes+" minutes are "+days+" days");
  }
}

Swift

// Write a Swift program to convert minutes to days

import Swift
import Foundation

var minutes = 7200

var days = minutes / 1440
print("Days: ", days)

TypeScript

// Write a TypeScript program to convert minutes to days

const minutesToDays = (minutes: number): number => {
  return minutes / 24 / 60;
};

console.log(minutesToDays(7200));

Similar programs