PRIME OR NOT
Code :
#include<stdio.h>
int main()
{
int n, flag = 0;
printf("Enter an positive integer: ");
scanf("%d", &n);
if(n == 1 || n == 0)
{
flag = 1;
}
for(int i=2; i<= n/2; ++i)
{
if(n%i == 0)
{
flag = 1;
}
}
if(flag == 1)
{
printf("\n\tNon Prime Number");
}
else
{
printf("\n\tA Prime NUmber");
}
return 0;
}
Come again Learn again !
< iCodeBuzz />
No comments:
Post a Comment