1.

Write a program to print square of odd numbers between21 and 40 ( both numbers included ) using while loop ?​

Answer»

Answer:

The given program is written in Java.

PUBLIC class Squares    {

   public static void MAIN(STRING args[])  {

       int i=21;

       System.out.println("Squares of NUMBERS in the range (21-40) are as follows..");

       while(i<=40){

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

           ++i;

       }

   }

}

Algorithm:

  • Looping through numbers in the range (21-40).
  • Displaying the square of each number.

Refer to the attachment for output.

•••♪



Discussion

No Comment Found