# Program to convert minutes to seconds

Last Updated : 15 Feb, 2024

Given an integer N, the task is to convert N minutes to seconds.

Note: 1 minute = 60 seconds

Examples:

Input: N = 5
Output: 300 seconds
Explanation: 5 minutes is equivalent to 5 * 60 = 300 seconds

Input: N = 10
Explanation: 600 seconds
Output: 10 minutes is equivalent to 10 * 60 = 600 seconds

Approach: To solve the problem, follow the below idea:

We know that 1 minute is equal to 60 seconds, so to convert N minutes to seconds, we can simply multiply N with 60 to get the total number of seconds.

Step-by-step approach:

• Take the input as the number of minutes N.
• Convert minutes to seconds by multiplying N with 60 and store it in ans.
• Print the final answer as ans.

Below is the implementation of the above approach:

## C++

 `#include ` `using` `namespace` `std;`   `// Function to convert minutes to seconds` `int` `convertMinutesToSeconds(``int` `N)` `{` `    ``int` `ans = N * 60;` `    ``return` `ans;` `}`   `int` `main()` `{` `    ``// Input the number of minutes` `    ``int` `N = 10;` `    ``cout << convertMinutesToSeconds(N) << ``" seconds"` `        ``<< endl;` `}`

## Java

 `import` `java.util.Scanner;`   `public` `class` `ConvertMinutesToSeconds {` `    ``// Function to convert minutes to seconds` `    ``static` `int` `convertMinutesToSeconds(``int` `N) {` `        ``// Multiply the number of minutes by 60 to get the equivalent seconds` `        ``int` `ans = N * ``60``;` `        ``return` `ans;` `    ``}`   `    ``public` `static` `void` `main(String[] args) {` `        ``// Input the number of minutes` `        ``int` `N = ``10``;`   `        ``// Call the function and print the result` `        ``System.out.println(convertMinutesToSeconds(N) + ``" seconds"``);` `    ``}` `}`

## Python3

 `# Function to convert minutes to seconds` `def` `convert_minutes_to_seconds(N):` `    ``ans ``=` `N ``*` `60` `    ``return` `ans`   `# Main function` `if` `__name__ ``=``=` `"__main__"``:` `    ``# Input the number of minutes` `    ``N ``=` `10`   `    ``# Call the function and print the result` `    ``print``(f``"{convert_minutes_to_seconds(N)} seconds"``)`

## C#

 `using` `System;`   `class` `Program` `{` `    ``// Function to convert minutes to seconds` `    ``static` `int` `ConvertMinutesToSeconds(``int` `N)` `    ``{` `        ``int` `ans = N * 60;` `        ``return` `ans;` `    ``}`   `    ``static` `void` `Main()` `    ``{` `        ``// Input the number of minutes` `        ``int` `N = 10;` `        ``Console.WriteLine(ConvertMinutesToSeconds(N) + ``" seconds"``);` `    ``}` `}` `//This ccode is contribited by Aman`

## Javascript

 `// Function to convert minutes to seconds` `function` `convert_minutes_to_seconds(N) {` `    ``let ans = N * 60;` `    ``return` `ans;` `}`   `// Main function` `if` `(``true``) {` `    ``// Input the number of minutes` `    ``const N = 10;`   `    ``// Call the function and print the result` `    ``console.log(`\${convert_minutes_to_seconds(N)} seconds`);` `}`

Output

```600 seconds
```

Time Complexity: O(1)
Auxiliary Space: O(1)

Previous
Next