Popular Posts

Tuesday, October 19, 2010

OOPs programme

class Gcd
{
 public static void main(String args[])
 {
 
  int n1=(int)(Math.random()*100);
  int n2=(int)(Math.random()*100);
  System.out.println("First generated no. is"+n1);
  System.out.println("Second generated no. is"+n2);
  int max,min,i;
  if(n1>n2)
   {
     max=n1;
     min=n2;
   } 
  else
  {
   max=n2;
   min=n1;
  }
  System.out.println("Max is ="+max+" Min is ="+min);
 
  one: for(i=min;i>=1;i--)
  {
    if(max%i==0)
    {
     if(min%i==0)
     System.out.println("Output is "+i);
     else
     continue one;
   
    }
    if(max%i>0)
   
   
    System.out.println("GCD of no is =1");
   
  }
 } 
}