Write a program in ‘C’ to print automorphic numbers. The automorphic number is a number in which the square of the number contains the number in the end. Example: (a) 5; 25 (b) 6; 36. 10m Dec2005
#include<stdio.h>
void main()
{
int SQ,i,NUM;
clrscr();
printf(“AUTOMORPHIC NUMBERS BETWEEN 0 TO 999 ARE : “);
for(i=2;i<10;i++)
{
SQ=i*i;
NUM=SQ%10;
if(i==NUM)
printf(“\nNUMBER = %d SQUARE = %d”,NUM,SQ);
}
for(i=10;i<100;i++)
{
SQ=i*i;
NUM=SQ%100;
if(i==NUM)
printf(“\nNUMBER = %d SQUARE = %d”,NUM,SQ);
}
getch();
}
[codesyntax lang=”c”]
#include<stdio.h> void main() { int SQ,i,NUM; clrscr(); printf("AUTOMORPHIC NUMBERS BETWEEN 0 TO 999 ARE : "); for(i=2;i<10;i++) { SQ=i*i; NUM=SQ%10; if(i==NUM) printf("\nNUMBER = %d SQUARE = %d",NUM,SQ); } for(i=10;i<100;i++) { SQ=i*i; NUM=SQ%100; if(i==NUM) printf("\nNUMBER = %d SQUARE = %d",NUM,SQ); } getch(); }
[/codesyntax]
Screen Shots:-