Toggle navigation
Home
Latest pastes
FAQ
Random
BitBin is shutting down!
Register
Login
Prime Number Program in C
SUBMITTED BY:
kaushal1981
DATE:
Feb. 22, 2017, 6:03 p.m.
FORMAT:
Text only
SIZE:
416 Bytes
Raw
Download
Tweet
HITS:
577
Go to comments
Report
#include <stdio.h>
main()
{
int n, c;
printf("Enter a number\n");
scanf("%d", &n);
if ( n == 2 )
printf("Prime number.\n");
else
{
for ( c = 2 ; c <= n - 1 ; c++ )
{
if ( n % c == 0 )
break;
}
if ( c != n )
printf("Not prime.\n");
else
printf("Prime number.\n");
}
return 0;
}
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus