Computer Science, asked by snehal1525, 5 months ago

write a program that print s the square of 10 even numbers in the range 10....100

Answers

Answered by SanchitaHatture
16

Answer:

class JavaExample {

public static void main(String args[]) {

int n = 100;

System.out.print("Even Numbers from 1 to "+n+" are: ");

for (int i = 1; i <= n; i++) {

//if number%2 == 0 it means its an even number

if (i % 2 == 0) {

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

}

}

}

}

Explanation:

hope it helps u mark me as brainliest plzz

Answered by biswajit2002sl
4

The question should be :

Write a program in JAVA to print the square of the even numbers from 10 to 100.

Answer:

public class Main {

   public static void main(String[] args) {

     

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

     {

       if(i%2==0)

       {

         int c = i*i;

         System.out.println(c+" ");

       }

     }

 }

}

Here, we start a loop that ranges from 10 to 100 and within the loop we check which of the numbers are even and after checking we store the result in a variable named as "c" (only the squares of the even numbers from 10 to 100), and then we print those numbers.

#SPJ2

Similar questions