Monday, January 18, 2021

BlueJ Program To Check A Number For Perfect Square Or Not


import java.util.*;
class Sw
{
   Scanner sc=new Scanner(System.in);
   int i,n,x;
   void show() 
   {
       System.out.println("\nEnter the number: ");
       n=sc.nextInt();
       for(i=2;i<n;i++)
       {
           if(n%i==0 && i==n/i)
           break;
        }
        if(i==n)
        System.out.println(n+ " is not a perfect square number");
        else
        System.out.println(n+ " is a perfect square number");            
    }

}


Other Programs On Numbers: CLICK HERE

No comments:

Post a Comment

Subscribe via email

Enter your email address:

Delivered by FeedBurner