when i assign rat other than 0 its work properly if i assign rat=0 it's not working properly if rat is other than 0 my program work properly and give me proper prime number
#include<stdio.h>
int main()
{
printf("\nenter a number");
int num,rat;
scanf("%d",&num);
for(int i=2;i<num;i++)
{
if(num%i==0)
{
rat=0;
break;
}
}
if(rat==0)
{
printf("\nit is not a prime number");
}
else
{
printf("\nit is a prime number");
}
}
Aucun commentaire:
Enregistrer un commentaire