So I'm trying to make a program that generates twin prime numbers between 1 and 1000. I think I got it, but I can't stop the looping it goes on forever. Here's my code so far:

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
  int a, c; 
  a=3;
  c=2;
        for (c=2; c<100; c++)
        {
            for (a=3; a != a%c; a++)
            {
                printf ("%d", a);
            }
        }
  } 
  system("PAUSE");  
  return 0;
}

I'm a beginner in C so please help.

try running this code...you'll be able to see your output which I cropped at 100

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
	int a, c;
	a=3;
	c=2;

	for (c=2; c<100; c++)
	{
		for (a=3; a != a%c; a++)
		{
			printf ("%d \n", a);
			if (a > 100) exit(EXIT_SUCCESS);
		}
	}

	system("PAUSE");
	return 0;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.