write a progra in c++ using class & object to find out
wheather a given no. is prim or not.
Answers were Sorted based on User's Feedback
Answer / ***..$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 |
Answer / rakesh ranjan
#include<conio.h>
void main()
{
int a,i;
printf("enter the number ");
scanf("%d",&a);
for(i=2;i<a;i++)
if(a%i==0)
{
printf("number is not Prime");
break;
}
if(i==a)
printf("Prime number");
getch();
}
Is This Answer Correct ? | 16 Yes | 6 No |
what is ltti
Is this job good for future? can do this job post grduate student?
what is difference between thread and programme.
What is the advantage of oop over procedural language?
write a c++ program to find maximum of two numbers using inline functions.
What is object in oops?
What is a linked list?
What is encapsulation c#?
What is the use of unnamed namespaces in OOPS? The only advantage I know is that they dont need the scope resolution operator while accessing them. I want to know some other advantages of unnamed namespaces...
How do you achieve polymorphism?
What is property in oops?
which structured data type is not used in c++? 1.union 2.structure 3.string 4.boolean