===========================================================================
CODING
#include<iostream.h>
#include<conio.h>
#include<math.h>
int Prime(int);
void main()
{
clrscr();
int n,i;
cout<<"Enter Number to check for Prime Number: ";
cin>>n;
i=Prime(n);
if(i==0)
cout<<"\n\nThe Number is Prime!!";
else
cout<<"\n\nThe Number is NOT Prime!!";
getch();
}
int Prime(int a)
{
int i,P;
for(P=0,i=2;i<=sqrt(a);i++)
if(a%i==0)
{
P=1;
break;
}
return P;
}
CODING
#include<iostream.h>
#include<conio.h>
#include<math.h>
int Prime(int);
void main()
{
clrscr();
int n,i;
cout<<"Enter Number to check for Prime Number: ";
cin>>n;
i=Prime(n);
if(i==0)
cout<<"\n\nThe Number is Prime!!";
else
cout<<"\n\nThe Number is NOT Prime!!";
getch();
}
int Prime(int a)
{
int i,P;
for(P=0,i=2;i<=sqrt(a);i++)
if(a%i==0)
{
P=1;
break;
}
return P;
}
===========================================================================
No comments:
Post a Comment