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 abstraction in oops with example?
A file pointer always contains the __________ of the file
What is interface in oop?
char* ptr = "Rahul"; *ptr++; printf("%s",ptr); What will be the output
how to write a java program for an output ****0 ***01 **012 *0123 01234
Can main method override?
How compiler selects(internally) required overridden function in inheritance?
2 Answers CSC, Infinite Computer Solutions,
What do you mean by pure virtual functions?
Contrast OOP and SOA. What are tenets of each?
1 Answers Siebel Systems, Wipro,
why oops need in programming
What are the types of abstraction?
Write pseudo code for push in a stack?