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