Pages

Showing posts with label MAGIC NUMBER IN BETWEEN MIN AND MAX VALUES. Show all posts
Showing posts with label MAGIC NUMBER IN BETWEEN MIN AND MAX VALUES. Show all posts

Saturday, 2 February 2019

MAGIC NUMBER IN BETWEEN MIN AND MAX VALUES

/*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 in between min and max values

#include<stdio.h>
void main()

{

 int min,max,j,i,k,n;

 printf("\nEnter min value:");

 scanf("%d",&min);

 printf("\nEnter max value:");

 scanf("%d",&max);
 printf("\nMagic numbers are:");

 for(n=min ;n<=max;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 ",n);
   
}
}


output:

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...