Computer Science, asked by moon8577, 4 months ago

Write a program to display all two digit numbers whose units digit is twice the tens digit .

Example- The numbers 12,24, 36 satisfies the above condition.

Iteration or Loops in Java.​

Answers

Answered by anindyaadhikari13
4

Required Answer:-

Question:

  • Write a program in Java to display all the two numbers whose unit digit is twice the tens digit.

Solution:

Here comes the program.

public class Number {

 public static void main(String[] args) {

    System.out.print("Numbers are:  ");

    for(int i=10;i<100;i++)  {

       int x=i%10, y=i/10;

       if(x==2*y)

          System.out.print(i+" ");

    }

 }

}

Algorithm:

  1. START
  2. Iterate a loop in the range 10 to 99.
  3. Find the last and first digit of each values of 'i'.
  4. Check if the ones digit is twice the tens digit. If true, display the value of 'i'
  5. STOP

Refer to the attachment for output ☑.

Attachments:
Similar questions