Answer Posted / garima gupta
#include<iostream.h>
#include<conio.h>
#include<math.h>
class prime
{
private:
int i,j,j;
public:
void readn();
void display();
};
void prime::readn()
{
clrscr();
cout<<"enter no. of prime nos you want to display:"<<endl;
cin>>n;
}
void prime::display()
{
int flag;
for(i=2;i<n;i++)
{
flag=0;
for(j=2;j<=sqrt(i);j++)
{
if(i%j==0)
{
flag=1;break;
}
else(flag==0)
{
cout<<i<<" ";
}
}
}
}
void main()
{
prime p;
p.readn();
p.display();
getch();
}
Is This Answer Correct ? | 10 Yes | 18 No |
Post New Answer View All Answers
How many types of modularization are there in c++?
What do you mean by translation unit in c++?
How to declare a function pointer?
Why is c++ not purely object oriented?
What is pointer to array in c++?
Which bit wise operator is suitable for putting on a particular bit in a number?
What things would you remember while making an interface?
Explain friend class?
How a modifier is similar to mutator?
What are the two types of comments?
What is c++ vb?
How many standards of c++ are there?
Can you overload the operator+ for short integers?
What is the difference between a type-specific template friend class and a general template friend class?
What is abstraction c++?