Pages

Saturday, 2 February 2019

PROGRAM TO FIND WHETHER THE GIVEN NUMBER IS MAGIC NUMBER OR NOT

/*PROGRAM TO FIND WHETHER THE GIVEN NUMBER IS MAGIC NUMBER OR NOT*/

A number is said to be a magic number if the reverse of the square of the number is equal to the given number reverse and its sqaure.

for eg: (12) sqaure =144 reverse of 144 is 441
            (21) square= 441

             (13) square=169 reverse of 169 is 961
             (31) sqaure=691

program:

// prg to illustrate magic number

#include<stdio.h>
void main()

{

 int j,i,k,n,temp;

 printf("\nENTER ANY NUMBER:");

 scanf("%d",&n);
 temp=n;
 while(i > n)

 {
       i=n*n;
    j=0;
    while(i>0)
    {
        j=j*10 + i% 10;
        i=i/10;
    }
    i=n;
    k=0;
    while(i>0)
    {
        k=k*10+i%10;
        i=i/10;
    }
    if(k*k==j)
     printf("\n%d is a Magic number\n ",temp);
    else
         printf("\n%d is not a Magic number\n ",temp);
  }
}
output:


No comments:

Post a Comment

Programs in turboc3 : Files

File Handling in C File Handling concept in C language is used for store a data permanently in computer. Using this concept we can store our...