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
Why is main function important?
What header file is needed for exit(); a) stdlib.h b) conio.h c) dos.h
What is the difference between a declaration and a definition?
Explain storage qualifiers in c++.
Can we use clrscr in c++?
What is conditions when using boolean operators?
What are literals in C++?
What is c++ code?
Will a recursive function without an end condition every quit, in practice a) Compiler-Specific (Some can convert to an infinite loop) b) No c) Yes
What are the various access specifiers in c++?
If dog is a friend of boy and boy is a friend of house, is dog a friend of house?
Write about the use of the virtual destructor?
What is the use of seekg in c++?
What is isdigit c++?
What does it mean to declare a member variable as static?