Write a program in C++ to find the prime numbers within a range of numbers by using the Virtual base Class in Object Oriented Programming(OOP).

#include<iostream>
using namespace std;
class A
{
protected:
int i,n;
};
class B:virtual public A
{
protected:
int T4Tutorials_StartingNum,T4Tutorials_EndigNum;
};
class C:virtual public A
{
protected:
int c;
};
class D:public B,public C
{
public:
int prime()
{
cout<<"enter starting no rnge"<<endl;
cin>>T4Tutorials_StartingNum;
cout<<"enter ending no rnge"<<endl;
cin>>T4Tutorials_EndigNum;
cout<<"the prime numbers btw"<<T4Tutorials_StartingNum<<" "<<T4Tutorials_EndigNum<<" ";
for(n=T4Tutorials_StartingNum;n<=T4Tutorials_EndigNum;n++)
{
c=0;
for(i=2;i<=n/2;i++)
{
if(n%i==0)
{
c++;
break;
}
}
if(c==0&&n!=1)
cout<<n<<" ";
}
cout<<endl;
}
};
int main()
{
D obj;
obj.prime();
}
FAQ
prime number program in c++ using class and object by using the Virtual base Class in Object Oriented Programming(OOP).
c++ program to print prime numbers up to n by using the Virtual base Class in Object Oriented Programming(OOP).
c++ program to find n prime numbers by using the Virtual base Class in Object Oriented Programming(OOP).
check whether the number is prime or not in c++ by using the Virtual base Class in Object Oriented Programming(OOP).
write a c++ program by using forloop to find that a number is prime or not a prime by using the Virtual base Class in Object Oriented Programming(OOP).
fastest way to check if a number is prime c++ by using the Virtual base Class in Object Oriented Programming(OOP).