Prints out the first eight autmorphic numbers
Create a program that prints out the first eight[8] automorphic numbers.
Output must be done int the main() function.
Here's the code I worked on:
#include <stdio.h>
#include <conio.h>
main() {
int automorphic [8];
int n;
printf("\t\t\tAUTOMORPHIC\n\n\n");
for(n=1; n<8; n++ ){
if (n*n%10==n || n*n%100==n || n*n%1000==n);
}
printf("\t%d\n\n", automorphic [n]);
getch();
return 0;
}
I don't get why it only prints out 0? Is there something missing on my
code? Or am I not doing the right thing at all?
No comments:
Post a Comment