Try this code :
C++ program to enter a no and print it is Prime number or not
Code:
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
int no, i;

cout << "Enter an integer : ";
cin >> no;
int limit = sqrt(no);
i = 2;
while(no%i != 0 && i <= limit)
i++;
if(i > limit)
cout<<no<<"
...