Given number is a prime or not
/*WAP to check
whether the given number is a prime or not*/
#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,s=0;
clrscr();
printf("enter
the number:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
if(n%i==0)
s++;
}
if(s==2)
printf("%d
is prime",n);
else
printf("%d
is not a prime",n);
getch();
}
OUTPUT:
enter the
number:19
19 is prime
No comments:
Post a Comment