A number is taken from user and is checked whether prime number or not.
Select To use this code as it is.. select and copy paste this code into code.cpp file :)
Select To use this code as it is.. select and copy paste this code into code.cpp file :)
- #include<iostream.h>
- #include<conio.h>
- void main()
- {
- clrscr();
- int n,m;
- cout<<"Please enter a number: ";
- cin>>n;
- for (int i=2;i<=(n-1);i++)
- {
- if(n%i==0)
- //Coding by: Snehil Khanor
- //http://WapCPP.blogspot.com
- {
- cout<<"Not a prime";
- break;
- }
- else
- {
- cout<<"Prime";
- break;
- }
- }
- getch();
- }