Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C Program

Name: Anonymous 2008-09-25 14:26

Programming newfag here. I'm trying to make a c program that determines whether a number is prime. It isn't working properly though. It only indicate that the number is not prime, regardless of the number, so something wrong. Anybody can help?

#include<stdio.h>

int main(void)
{

    int number;
    int count;
    int divisor = 2;
   
    printf("Input number for primality testing\n");
    scanf("d",number);
   
    while (divisor < number/2) {   
        if (number % divisor == 0) {
            break;   
        }
        else
            divisor++;
    }

    if (divisor == number/2) {
        printf("Number is prime\n");
    }
    else {
        printf("Number is not prime\n");
    }
    return 0;
}

Name: Anonymous 2008-09-26 6:48

>>31
ANONIX quality

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List