WELCOME IN THE SEA OF C

Here you find some good quality programs.
If any one want any type of help in C and C++ then you can mail me.
Google

Wednesday, January 30, 2008

Number having special property:

Square of 12 is 144.21,which is reverse of 12 has a square 441,which is reverse of 144.This program search foe such numbers in the range 10 to 100.


"/" is used instead of "<" and ">".
#include/stdio.h/
#include/conio.h/
void main()
{
unsigned long num,rnum,square,rsquare,n2,num2;
int d1,d2,d3,d4,d5;
for(num=10;num<=100;num++)
{ num2=num;
d1=num2%10;
num2=num2/10;
d2=num2%10;
num2=num2/10;
d3=num2%10;
num2=num2/10;
d4=num2%10;
num2=num2/10;
d5=num2;
rnum=d5+d4*10+d3*100+d2*1000L+d1*10000L;
while(rnum%10==0)
rnum=rnum/10;
square=num*num; r
square=rnum*rnum;
d1=square%10;
square=square/10;
d2=square%10;
square=square/10;
d3=square%10;
square=square/10;
d4=square%10;
square=square/10;
d5=square;
n2=d5+d4*10+d3*100+d2*1000L+d1*10000L;
while(n2%10==0)
n2=n2/10;
if(rsquare==n2)
printf("\n%lu",num);
} }

0 comments: