By DePaul Dimadis
Choose your prefered Language: greek_flag uk_flag

A twin prime is a prime number that is either 2 less or 2 more than another prime number—for example, either member of the twin prime pair (41, 43). In other words, a twin prime is a prime that has a prime gap of two. Sometimes the term twin prime is used for a pair of twin primes; an alternative name for this is prime twin or prime pair.

The first pairs of twin first numbers are: (3.5), (5.7), (11, 13), (17, 19), (29, 31), (41, 43), ...
Write a program in C language that it finds, and displays all the pairs of Prime numbers, only if both pair numbers are less than 1000. In the end, display the crowd of these pairs.
(NOTE: The following code section in C language finds if a positive integer number k ≥ 2 is a prime number.

i=2; flag=0;
while ((i<=k/2) && (flag==0))
{
   if (k%i==0) flag=1;
   i++;
}
if (flag==0) printf("number %4d is prime \n",k);