well this program was made so it could tell u the if the number entered is a prime number or not...but i aint workin'
Code:#include <stdio.h> int prime_number ( int ); int main() { int num1, sum; printf ("Enter a number:"); scanf ("%d", &num1 ); sum = prime_number ( num1 ); if ( sum == 1){ printf ("%d is not a prime number", num1 ); else if ( sum == 0 ) printf ("%d is a prime number", num1) return 0; } int prime_number ( int a) { int num2, tot; num2 = a/2; tot = a/num2; if ( tot == 2 ) return 1; else return 0; }



LinkBack URL
About LinkBacks


