C program for prime or not

#include<stdio.h>
int main()
{
int num,flag=0;
printf(“Enter a numbert”);
scanf(“%d”,&num);
//if the number is divisible by half of its number that is if n=6 then it is divided by 3 like n/3 and n is divided by 1,2,3 and if remainder is zero number is not prime
for(int i=2;i<=num/2;i++)
{
if(num%i==0)
{
flag=1;
break;
}
}

if (flag==1)

printf(“Not Primen”);
else
printf(“n Primen”);
}

out:
Enter a number 4
Not Prime

Leave a Comment

Your email address will not be published. Required fields are marked *

Hire a server Expert to resolve the issue Now.

Hire a server Expert to resolve the issue Now.

Resolve this issue in just 5$ from https://serverexpert.io

 

You have Successfully Subscribed!

Open chat