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 the prime no program in c++?

Answer Posted / prits

#include <iostream>
using namespace std;

void main()
{
int num;
int flag = 0;
cout<<"enter a number"<<endl;
cin>>num;
for(int i=2;i<num;i++)
{
if((num%i) == 0)
{
flag = 1;
break;
}
}
if (flag == 1)
cout<<"Not Prime"<<endl;
else
cout<<"Prime"<<endl;

}

Is This Answer Correct ?    32 Yes 15 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What do you mean by vtable and vptr in c++?

1097


Differentiate between late binding and early binding. What are the advantages of early binding?

1079


Define Virtual function in C++.

1148


What is tellg () in c++?

1360


What problems might the following macro bring to the application?

1097


If horse and bird inherit virtual public from animal, do their constructors initialize the animal constructor? If pegasus inherits from both horse and bird, how does it initialize animal’s constructor?

1259


What is the main purpose of overloading operators?

1208


What is a vector c++?

1250


Comment on assignment operator in c++.

1169


Why do we use constructor?

1113


Which operator cannot overload?

1101


What are friend classes? What are advantages of using friend classes?

1139


What is virtual destructor ans explain its use?

1170


what is Member Functions in Classes?

1283


Explain what are mutator methods in c++?

1181