Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
#include <stdio.h>
#include <stdlib.h>
int main ()
{
int x[6];
// the array looks like, 012345
int a, b, c, d, i;
a = 100;
b = 100;
c = 100;
d = 100;
do
{
i = a * b;
// i is the product of a and b
x[0] = (i / 100000);
// sets i/100000 as the first digit of the number Ex. 987654/100000=9.8 sets x[0] as 9
x[1] = (i / 10000) - (x[0] * 10);
// sets (i/10000) - the first digit*10 as the second number Ex. 987654 / 100000=9.8=9, 987654 / 10000=98 then 98 - (x[0]*10)=8, sets x[1] as 8
x[2] = (i / 1000) - (x[0] * 100) - (x[1] * 10);
x[3] = (i / 100) - (x[0] * 1000) - (x[1] * 100) - (x[2] * 10);
x[4] =
(i / 10) - (x[0] * 10000) - (x[1] * 1000) - (x[2] * 100) -
(x[3] * 10);
x[5] =
(i / 1) - (x[0] * 100000) - (x[1] * 10000) - (x[2] * 1000) -
(x[3] * 100) - (x[4] * 10);
if (a < 1000)
{
a++;
}
// as long as A is less than 1000 it will add 1 to A
else
{
a = d;
d++;
b = c + 1;
c = b;
}
// if A is 1000 it will turn A back to 100, add 1 to the returning number, adds 1 to B also to multiply every number from 1 to 1000 by every number 1 to 1000
if (x[0] == x[5] && x[1] == x[4] && x[2] == x[3] && x[0] != 0 && x[0] == 9)
{
printf ("%d%d%d%d%d%d\n", x[0], x[1], x[2], x[3], x[4], x[5]);
}
// checks if it is a palindrome, 123321 or 554455 etc
}
while (a < 1001);
return 0;
}
Advertisements
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.
AcceptLearn more