This is just a simple program for Prime Number. Logic is simple. Checking the inputed number if it is divided by 2 or not. We just need to use a for loop. If you any other efficient code feel free to share with us.
Here is my Code:
int n, i, prime = 1;
printf(“Enter a positive number: \n”);
for(i=2; i<=n/2; ++i)
printf(“%d is a prime number. \n”,n);
printf(“%d is not a prime number. \n”,n);