Computer Science, asked by tonny45891, 6 months ago

Write a program to print the square of first 10 natural numbers but if a square encountered which is divisble by 2,3 and 4 skip then and there .

Answers

Answered by anindyaadhikari13
7

\star\:\:\:\sf\large\underline\blue{Question:-}

  • Write a program to print the square of first 10 natural numbers but if a square encountered which is divisible by 2,3 and 4,skip then and there.

\star\:\:\:\sf\large\underline\blue{Program:-}

The given code is written in Java Language.

class Java

{

public static void main(String s[])

{

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

{

int x=i*i;

if(x%2==0 || x%3==0 || x%4==0)

continue;

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

}

} // end of main()

} // end of class.

Similar questions