/* ***********************************************
Write a program to find prime number or not
date:30-05-2019
created by:ANIL DURGAM
*****************************************************/
#include <stdio.h>
#include <stdlib.h>
main()
{
int n, c = 2;
printf("Enter a number to check if it is prime\n");
scanf("%d",&n);
for ( c = 2 ; c <= n - 1 ; c++ )
{
if ( n%c == 0 )
{
printf("%d isn't prime.\n", n);
break;
}
}
if ( c == n )
printf("%d is prime.\n", n);
return 0;
}
No comments:
Post a Comment