NOTE :
// indicates comments.This wont get printed in the output.This is used for for documentation purpose.
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
int num,i, p=0; //p is no. of prime divisors
clrscr();
printf("Enter any number\t :\t");
scanf("%d",&num);
for(i=2;i<=num/2;i++)
{
if(num%i==0)
{
++p;
break;
}
}
if(p==0)
{
printf("%d is a PRIME NUMBER\n",num);
}
else
{
printf("%d is not a PRIME NUMBER",num);
}
getch();
}
OUTPUT :
// indicates comments.This wont get printed in the output.This is used for for documentation purpose.
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
int num,i, p=0; //p is no. of prime divisors
clrscr();
printf("Enter any number\t :\t");
scanf("%d",&num);
for(i=2;i<=num/2;i++)
{
if(num%i==0)
{
++p;
break;
}
}
if(p==0)
{
printf("%d is a PRIME NUMBER\n",num);
}
else
{
printf("%d is not a PRIME NUMBER",num);
}
getch();
}
OUTPUT :


0 comments: