Write a C program to determine whether a number is a prime or not.
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,n,b=0;
clrscr();
printf("Please enter a number:");
scanf("%d",&n);
if(n==1)
printf("%d is not a prime number",n);
else
{
for(i=2;i<n;i++)
if(n%i==0)
{
b=1;
break;
}
if(b==1)
printf("%d is not a prime number",n);
else
printf("%d is a prime number",n);
}
getch();
}
#include<conio.h>
void main()
{
int i,j,n,b=0;
clrscr();
printf("Please enter a number:");
scanf("%d",&n);
if(n==1)
printf("%d is not a prime number",n);
else
{
for(i=2;i<n;i++)
if(n%i==0)
{
b=1;
break;
}
if(b==1)
printf("%d is not a prime number",n);
else
printf("%d is a prime number",n);
}
getch();
}