#include<stdio.h>
void main()
{
int n,i,fl=0; //Declaration of variables
clrscr();
printf("\nEnter a Number : ");
scanf("%d",&n); //Initialization of number from user
for(i=2;i<n;i++) //For Loop for checking prime number
{
if(n%i==0) //Checking if the number can be divided
{ //by any other number other
fl=1;
}
if(fl==1) //Checking for result
printf("\n%d is Not a Prime Number ",n); //Display Result
else
printf("\n%d is a Prime Number ",n);
printf(“\nPress any Key to Continue………”);
getch();
}
Output :
Enter a Number : 11
11 is a Prime Number
Press any Key to Continue……
Enter a Number : 4
4 is Not a Prime Number
Press any Key to Continue…………
No comments:
Post a Comment