#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    1
    Rep Power
    0

    Twin Prime Pairs


    I already wrote some code to find prime numbers, now I have to write some code that prints out all the twin prime pairs under 1000... suggestions?

    my code so far:

    int x, m = 2;

    printf("Enter a number to check if it is prime\n");
    scanf("%d",&x);

    for( m = 2 ; m*m <= x, ++m; ) {

    if( n %m == 0 ){

    printf("%d is not prime.\n", x);
    break;
    }
    }
    if( m == n ){
    printf("%d is prime.\n", x);
    }


    thanks :)

    P.S. I'm a super beginner, only been at this for a month or two. Be gentle if the above is wacky.
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,837
    Rep Power
    480
    You don't have a program that prints prime numbers.
    You don't have a program at all.

    Start with writing hello world,
    learn to use the compiler,
    learn the essentials of a c program.
    Turn on compiler warnings and address the issues that arise.

    If you'd like accolades, your absolute beginner non-program is in some ways a good deal better than other absolute beginner nonsense that come through this forum.
    Last edited by b49P23TIvg; March 21st, 2013 at 07:52 AM.
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo