#include<stdio.h>
void main()
{
int i, prime = 1, n;
clrscr();
printf(“nnt ENTER A NUMBER…: “);
scanf(“%d”, &n);
for(i=2; i<n; i++)
{
if(n%i == 0)
{
prime = 0;
break;
}
}
if(prime)
printf(“nnt THE NUMBER %d IS A PRIME NUMBER”, n);
else
printf(“nnt THE NUMBER %d IS NOT A PRIME NUMBER”, n);
getch();
}
Not Satisfied ? Just search & get the result
Related posts:
- C Program to find the prime numbers below a given number.
- C Program to find the prime numbers between a given range
- C program to generate and print prime numbers in a given range. Also print the number of prime numbers
- C program to check whether a given number is prime or not and output the given number with suitable message
- C Program for perfect numbers

{ 1 comment… read it below or add one }
C Program for prime numbers