Menu
Question Index
...

Write a program to get number of 2's present between 0 and given number N including N.

Input (int) Output (int)
12 [2], 1[2] = 2
112 [2], 1[2], [2]0, [2]1, [2][2], [2]3, [2]4, [2]5, [2]6, [2]7, [2]8, [2]9, 3[2], 4[2], 5[2], 6[2], 7[2], 8[2], 9[2], 10[2], 11[2] = 22
555 216
765 257
1079 318



class CountNumberOfTwos
{
    public static void main(String s[])
    {
        int number = 222;
        System.out.println("Number of 2's present between zero and " + number + " are " + getTwosCount(number));

    }


    public static int getTwosCount(int number) {
    }

}

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