#include<iostream.h>
#include<conio.h>
void prime(int n);
void main()
{
clrscr();
int num;
cout<<"Enter a number: ";
cin>> num;
prime(num);
getch();
}
void prime(int n)
{
int p =1;
for(int j=2; j<n; j++)
if(n%j == 0)
{
p = 0;
break;
}
if(p == 1)
cout<<"The number is prime";
else
cout<<"The number is not prime";
}
#include<conio.h>
void prime(int n);
void main()
{
clrscr();
int num;
cout<<"Enter a number: ";
cin>> num;
prime(num);
getch();
}
void prime(int n)
{
int p =1;
for(int j=2; j<n; j++)
if(n%j == 0)
{
p = 0;
break;
}
if(p == 1)
cout<<"The number is prime";
else
cout<<"The number is not prime";
}
0 comments:
Post a Comment