write a progra in c++ using class & object to find out
wheather a given no. is prim or not.
Answer Posted / ***..$indhu..***
#include<iostream.h>
#include<conio.h>
class prime
{
int n,i;
public:
void giveno(int);
void no_prime();
};
void prime::giveno(int a)
{
n=a;
}
void prime::no_prime()
{
i=2;
if(i<=n-1)
{
if(n%i==0)
{
cout<<endl<<"not prime no";
else
cout<<endl<<"prime no";
break;
}
if(n==i)
{
cout<<endl<<"prime no";
}
}
}
int main()
{
prime p1;
p1.giveno(5);
p1.no_prime();
return 0;
}
| Is This Answer Correct ? | 33 Yes | 10 No |
Post New Answer View All Answers
What is inheritance in oop?
Where You Can Use Interface in your Project
What are the 4 pillars of oop?
what is the drawback of classical methods in oops?
How do you define social class?
Can static class have constructor?
What is abstraction in oops?
i got a backdoor offer in process global,Bangalore..Can i work with it?
write a program using c++ to implement single contiguous memory mangement techniques.display the content of the main memory after yhe allocation of jobs and percentage of the wastage of the main memory
How to hide the base class functionality in Inheritance?
Why do we use polymorphism?
Whats oop mean?
explain sub-type and sub class? atleast u have differ it into 4 points?
What is the important feature of inheritance?
How do you answer polymorphism?