Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Write a function to convert a decimal number to its binary representation.

Hard

Problem Statement

Write a function to convert a decimal number to its binary representation.

Sample Input

A hardcoded number, e.g., 10.

Sample Output

Binary representation of 10 is: 1010

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
fun decimalToBinary(number: Int): String { // Add your code here to convert to binary } fun main() { val number = 10 println("Binary representation of $number is: ${decimalToBinary(number)}") }
Log in or sign up to run or submit your code.Log inSign up
Input
A hardcoded number, e.g., 10.
Expected Output
Binary representation of 10 is: 1010