Prime Number in C language
Prime Number is a whole number greater than 1 whose only factors are 1 and itself. A factor is a whole numbers that can be divided evenly into another number.
the example of prime number is 2,3,5,7,11,13,17,19 and so on.
now we will make a code in C to determine is it prime number or not
#include<stdio.h>
int main()
{
int num,n,check;
scanf("%d",&num);
check=0;
for(n=1;n<=num;n++)
{
if(num%n==0)check++;
}
if(check==2)printf("%d is Prime Number",num);
else printf("%d is Not Prime Number",num);
return 0;
}
in some competitive coding you will get time limit if you use this code
many ways to make this coding
That is all from me
thank you
Comments
Post a Comment