12 hour clock Multiplication Last Updated : 11 Nov, 2022 Comments Improve Suggest changes Like Article Like Report Given two positive integers num1 and num2, the task is to find the product of the two numbers on a 12-hour clock rather than a number line. Note: Assume the Clock starts from 0 hours to 11 hours. Examples: Input: Num1 = 3, Num2 = 7Output: 9Explanation: 3*7 = 21. The time in a 12 hour clock is 9. Input: Num1 = 3, Num2 = 4Output: 0 Approach: Follow the steps to solve this problem: Calculate Product as Num1*Num2 and store it in a variable Prod.If Prod = 12, return 0.Else If Prod ? 0 and Prod ? 11, return Prod.Else return, Prod % 12. Note: You can skip all the steps and return (Num1*Num2) % 12 also, it also works fine. Below is the implementation of the above approach. C++ // C++ code to implement the approach #include <bits/stdc++.h> using namespace std; // Function to find the product of // the two numbers on a 12-hour clock int multiClock(int Num1, int Num2) { return (Num1 * Num2) % 12; } // Driver Code int main() { int num1 = 3, num2 = 7; // Function Call cout << multiClock(num1, num2) << endl; return 0; } Java // Java code for the above approach import java.io.*; class GFG { // Driver Code public static void main (String[] args) { int num1 = 3, num2 = 7; // Function Call System.out.println(multiClock(num1, num2)); return; } // Function to find the product of the two numbers on a 12-hour clock static int multiClock(int Num1, int Num2) { return (Num1 * Num2) % 12; } } // This code is contributed by ajaymakvana. Python3 # Python code to implement the approach # Function to find the product of the two numbers on a 12-hour clock def multiClock(Num1,Num2)->int: return (Num1*Num2) % 12 # Driver Code if __name__ == '__main__': num1 = 3 num2 = 7 # Function Call print(multiClock(num1,num2)) # This code is contributed by ajaymakvana. C# // C# code to implement the approach using System; class GFG { // Function to find the product of // the two numbers on a 12-hour clock static int multiClock(int Num1, int Num2) { return (Num1 * Num2) % 12; } // Driver code public static void Main(string[] args) { int num1 = 3, num2 = 7; // Function Call Console.Write(multiClock(num1, num2)); } } // This code is contributed by code_hunt. JavaScript <script> // JS code to implement the approach function multiClock(Num1, Num2) { return (Num1 * Num2) % 12; } // Driver Code let num1 = 3, num2 = 7; // Function Call document.write(multiClock(num1, num2)); // This code is contributed by Potta Lokesh </script> Output9 Time Complexity: O(1)Auxiliary Space: O(1) 12 hour clock Multiplication | DSA Problem Comment More infoAdvertise with us Next Article Modular Multiplication A akashjha2671 Follow Improve Article Tags : Computer Science Fundamentals Modular Arithmetic Practice Tags : Modular Arithmetic Similar Reads Modular Multiplication Given three integers a, b, and M, where M is the modulus. Compute the result of the modular multiplication of a and b under modulo M.((aÃb) mod M)Examples:Input: a = 5, b = 3, M = 11Output: 4Explanation: a à b = 5 à 3 = 15, 15 % 11 = 4, so the result is 4.Input: a = 12, b = 15, M = 7Output: 5Explana 6 min read Modular Multiplication Given three integers a, b, and M, where M is the modulus. Compute the result of the modular multiplication of a and b under modulo M.((aÃb) mod M)Examples:Input: a = 5, b = 3, M = 11Output: 4Explanation: a à b = 5 à 3 = 15, 15 % 11 = 4, so the result is 4.Input: a = 12, b = 15, M = 7Output: 5Explana 6 min read Modular Multiplication Given three integers a, b, and M, where M is the modulus. Compute the result of the modular multiplication of a and b under modulo M.((aÃb) mod M)Examples:Input: a = 5, b = 3, M = 11Output: 4Explanation: a à b = 5 à 3 = 15, 15 % 11 = 4, so the result is 4.Input: a = 12, b = 15, M = 7Output: 5Explana 6 min read Binary Multiplication Binary Multiplication is a mathematical operation that involves multiplying two binary numbers, which are numbers composed of only 0s and 1s. Binary multiplication is similar to decimal multiplication, except that the base of the number system is 2 instead of 10. Binary multiplication involves multi 8 min read Area Model Multiplication Area Model Multiplication is a powerful technique used to simplify the multiplication process, especially for larger numbers. It helps students understand the concept of multiplication visually and can be a great tool for educators. This guide will introduce you to the concept of Area Model Multipli 6 min read How to Multiply Decimal by 2-digits To multiply a decimal by a 2-digit number, ignore the decimal and multiply as usual. Then count the decimal places in the original decimal number and place the decimal point in the product, ensuring it matches the original number of decimal places.In this article, we will discuss this in detail.What 4 min read Like