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
7
- 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.
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