Prime number in C|Learnerspage

0
48
Prime number in C

#include <stdio.h>
#include <conio.h>
void main()
{
int i, num, p = 0;
printf(“Enter a number: \n”);
scanf(“%d”, &num);
for(i=2; i<num; i++)
{
if(num%i==0)
{
p++;
}
}
if(p>1)
{
printf(“Entered number %d is not a prime number.”,num);
}
else
{
printf(“Entered number %d is a prime number.”,num);
}
getch();
}

LEAVE A REPLY

Please enter your comment!
Please enter your name here