The BOTTOM LINE Quote Of The Day

The BOTTOM LINE Quote Of The Day

Don't Ever Tell GOD How BIG Your Problems are.
Just Tell Your Problems How BIG your GOD is ;)

Sunday, May 27, 2012

Finding a 4-Digit Perfect Square Number of order AABB


#include<stdio.h>
#include<conio.h>
#include<math.h>

int main()
{
  int a=1,b=0,i,nm,nms;
  while(1)
  {
   
    nm = 0;
    for(i=1;i<=4;i++)
    {
     if(i<=2)              
      nm = nm*10 + a;
     else
      nm = nm*10 + b;
    }      
    nms = sqrt(nm);
    if(nm==(nms*nms))
    {
     printf("%d is Perfect Square Number of order AABB",nm);                    
     break;  
    }
    else
    {
     b = (++b)%10;
    if(b == a)
     b = (++b)%10;  
    if(b==0)
     ++a;  
    }
  }
  getch();
  return 0;
}

No comments:

Post a Comment