google-site-verification: googlef8aa845b858144d3.html COMPUTER SCIENCE NOTES: PRIME NUMBER (Example 3)

Monday, July 17, 2017

PRIME NUMBER (Example 3)

/* 3 program of prime number Note=> 1 is not prime number */
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int i,n,flag=0;
clrscr();
printf("Enter a number:");
scanf("%d",&n);
for(i=2;i<=sqrt(n);i++)
{
if(n%i==0)
flag=1;
}
if(flag==1)
printf("Not prime number ");
else
printf("Prime number ");
getch();
}

No comments:

Post a Comment