#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.
Learn Python Programming for Beginners: Best Step-by-Step Guide for Coding with Python, Great for Kids and Adults. Includes Practical Exercises on Data Analysis, Machine Learning and More.
The Advanced Roblox Coding Book: An Unofficial Guide, Updated Edition: Learn How to Script Games, Code Objects and Settings, and Create Your Own World!