In this program, the user is ask to enter a number, then that number is determined whether it is Prime or not. Prime numbers are special numbers, greater than 1, that have exactly two factors, themselves and 1. 19 is a prime number. It can only be divided by 1 and 19. The prime numbers below 20 are: 2, 3, 5, 7, 11, 13, 17, 19. ...
#include <stdio.h>
#include<conio.h>
void main()
{
int no, i, isPrime = 1;
printf("Enter the number : ");
scanf("%d", &no);
for (i = 2; i <= no/2; i++)
{
if (no % i == 0)
{
isPrime = 0;
break;
}
}
if (isPrime == 1)
{
printf("%d is a Prime number", no);
}
else
{
printf("%d is not a Prime number", no);
}
return 0;
}
Enter the number : 17
17 is a Prime number
Enter the number : 74
74 is not a Prime number