Problem Description
George uncle taught that A prime number (or a prime) is a natural number greater than 1 that has no positive divisors other than 1 and itself. A natural number greater than 1 that is not a prime number is called a composite number.Guide George in writing a C code to find whether the number is PRIME number or not.CODING ARENA
#include <stdio.h>
int main()
{
int a,i,x=0;
scanf("%d",&a);
for(i=2;i<=a/2;i++)
{
if(a%i==0)
{
x=1;
}
}
if(x==0)
printf("%d is a prime number",a);
else
printf("%d is not a prime number",a);
return 0;
}
Test Case 1
Input (stdin)1234
Expected Output1234 is not a prime number
Test Case 2
Input (stdin)2
Expected Output2 is a prime number
Super
ReplyDelete