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 is general format for a prototype?

1042


Explain the uses of static class data?

1111


How should runtime errors be handled in c++?

1151


What is a singleton class c++?

1038


Is c++ slower than c?

1040


When there is a global variable and local variable with the same name, how will you access the global variable?

1101


Why do we need constructors in c++?

1112


Difference between a homogeneous and a heterogeneous container

1145


Why is c++ called oops?

1180


Is arr and &arr are same expression for an array?

1057


Does improper inheritance have a potential to wreck a project?

1157


What is the need of a destructor?

1146


What are the differences between malloc() and calloc()?

1186


Is c++ the hardest language?

990


Why is c++ awesome?

1035