I'm working on a program for a class:

Write a program that asks for an integer from the user and determines whether or not the integer is odd or even, then determines if that number is a prime number.

I have it working almost perfectly, but the problem I'm finding is that it says that 1 and 4 are prime numbers. All the other numbers i check are correct except 1 and 4. Does anyone know why this is?

Here is the code I have so far:

Code:#include <stdio.h> int main ( void ) { int integer; int x; printf( "Enter an integer (-1 to end): " ); scanf( "%d", &integer ); while( integer != -1 ) { if( integer % 2 == 0 ) { printf( "The number you have entered is an even number.\n" ); } else { printf( "The number you have entered is an odd number.\n" ); } for( x = 2; x < integer / 2; x++ ) { if( integer % x == 0 ) { printf( "The number you have entered is not a prime number.\n" ); break; } } if( !( x < integer / 2 )) { printf( "The number you have entered is a prime number.\n" ); } printf( "Enter an integer (-1 to end): " ); scanf( "%d", &integer ); } return 0; }