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 Difeerence between List obj=new ArrayList(); and ArrayList obj=new ArrayList()?
Write a program to compute for numeric grades for a course. The course records are in a file that will serve as the input file. The input file is in exactly the following format: Each line contains a student's first name, then one space, then ten quiz scores all on one line. The quiz scores are in whole number and are separated by one space. Your program will take it input from this file and sends it output to a second file. The data in the output file will be exactly the same as the data in the input file except that there will be one additional number (of type double) at the end of each line. This number will be the average of the student's ten quiz scores. Use at least one function that has file streams as all or some of its arguments.
What does oop mean in snapchat?
What is oops concept with example?
Why do we use inheritance?
write a programe to calculate the simple intrest and compund intrest using by function overlading
What is cohesion in oop?
What is inheritance in oop?
How Do you Code Composition and Aggregation in C++ ?
what are the different types of qualifier in java?
What is coupling in oops?
What is super in oop?
What is the difference between a constructor and a destructor?
Plese get me a perfect C++ program for railway/airway reservation with all details.
if i have same function with same number of argument but defined in different files. Now i am adding these two files in a third file and calling this function . which will get called and wht decide the precedence?