#include<stdio.h>
#include<conio.h>
void main()
{
int n, i, count=0;
clrscr();
printf("\nEnter a number: ");
scanf("%d",&n);
for(i=2;i<=n/2;i++)
{
if(n%i==0)
{
count++;
break;
}
}
if(count==0)
{
printf("%d is a prime number",n);
}
else
{
printf("%d is not a prime number",n);
}
getch();
}
OUTPUT:
Enter a number: 11
11 is a prime number
Enter a number: 25
25 is not a prime number
#include<conio.h>
void main()
{
int n, i, count=0;
clrscr();
printf("\nEnter a number: ");
scanf("%d",&n);
for(i=2;i<=n/2;i++)
{
if(n%i==0)
{
count++;
break;
}
}
if(count==0)
{
printf("%d is a prime number",n);
}
else
{
printf("%d is not a prime number",n);
}
getch();
}
OUTPUT:
Enter a number: 11
11 is a prime number
Enter a number: 25
25 is not a prime number
Comments
Post a Comment