You are on page 1of 1

5. Write a program to check no. is prime or not.

# include <io stream.h>


#include <conio.h>
#include <math.h>
void main ( )
{
int n,i,num;
clrscr( );
cout <<\n enter the positive integer value N\n;
cin >> n;
for ( i = 2; i <= n; i ++ )
{
if ( num%i = = 0 )
{
break;
}
}
if ( num = = i )
cout <<this is prime no.;
cout <<this is not prime no.;
getch( );
}

Output:enter the positive integer value M


17
this no. is prime no.
enter the positive integer value N
15
this no. is prime no.

You might also like