Math, asked by amsaelangovan6774, 1 year ago

How to find out prime numbers between two numbers c++?

Answers

Answered by lifeislife
0

#include<iostream.h>

#include<conio.h>

void main()

{

int a,b,i,j;

cout << "Enter two numbers to find prime no bet. them ";

cin >>a;

cin>> b;

cout << "Prime no between \t" << a << " and \t" << b << " are\n ";

while (a < b)

{

j = 1;

for(i = 2; i <= b/2; i++)

{

if(a % i == 0)

{

j = 0;

break;

}

}

if (j == 1)

{cout << a << " \t";}

++a;

}

return 0; }

Similar questions