Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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



write a progra in c++ using class & object to find out wheather a given no. is prim or not. ..

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

write a progra in c++ using class & object to find out wheather a given no. is prim or not. ..

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

Post New Answer

More OOPS Interview Questions

Please send ford technologies placement paper 2 my mail id

0 Answers  


whats the difference between c and c++

7 Answers   Syntel,


What is a linked list?

10 Answers   IBM, Neural Info,


What is coupling in oops?

0 Answers  


what do you mean by static member variable?

2 Answers  


what is the difference between containership and inheritence?

1 Answers  


What are different oops concepts?

0 Answers  


which structured data type is not used in c++? 1.union 2.structure 3.string 4.boolean

2 Answers   HCL, Wipro,


all about pointers

2 Answers  


Why is it so that we can have virtual constructors but we cannot have virtual destructors?

2 Answers  


what is different between oops and c++

0 Answers   IIT,


function overridind means and simple program

2 Answers  


Categories