Menu
Question Index
...

Write a program to get number of bits that needed to be flipped to convert from one number to another number.

Input (int, int) Output (int)
2, 1 2
4, 16 2
15, 4 3
18, 16 1



class NumberOfBitsFlipped
{
    public static void main(String s[])
    {
        int fromNumber = 2, toNumber = 1;
        System.out.println("Number of bits needed to be flipped to convert " + fromNumber + " to " + toNumber + " is " + getNumberOfFlips(fromNumber, toNumber));

    }


    public static int getNumberOfFlips(int fromNumber, int toNumber) {
    }

}

Doubts

Problems

Topic: Java for loops vs Java while loops vs Java do while loops

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App