#include<stdio.h>
#include<conio.h>
void main(){
int n,i,j=0;
clrscr();
printf("\nEnter the number:");
scanf("%d",&n);
// *LOGIC*
for(i=1;i<=n;i++)
{
if(n%i==0)
j++;
}
if(j==2)
{
printf("\nEntered Number");
textcolor(YELLOW);
cprintf("%2d" ,n);
printf("is Prime");
}
else
{
printf("\nEntered Number");
textcolor(YELLOW);
cprintf("%2d",n);
printf(" is not a Prime",n);
}
getch();
}
Output:
No comments:
Post a Comment