I did not understood this program
/*program to check whether a no is prime or not prime*/
#include<iostream.h>
#include<conio.h>
void main()
{int n,i=2,j=1;
cout<<"enter a no";
cin>>n;
while((i<n/2) &&(j==1))
{if(n%i==0)
j=0;
i++;
}
if(j==1)
cout<<endl<<"no is prime";
else
cout<<"no is not prime";
getch();
}
#include <iostream>
#include <conio.h>
usingnamespace std;
int main()
{
unsignedint number;
cout << "Enter a number: ";
cin >> number;
bool prime = true;
for ( unsignedint i = 2; i < number / 2; i++ )
{
if ( number % i == 0 ) prime = false, break;
}
if ( prime ) cout << "Number " << number << " is prime\n";
else cout << "Number " << number << " is not prime\n";
getch();
return ( 0 );
}
If a number is divisible by another number ( number % i == 0 ) then it is not a prime number.