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

List the issue that the auto_ptr object handles?

1024


What programming language should I learn first?

1090


What is the limitation of cin while taking input for character array?

2071


Which one is better- macro or function?

1187


What is a binary file? List the merits and demerits of the binary file usagein C++.

1296


What are manipulators in c++ with example?

1058


Should I learn c++ c?

1041


Can you please explain the difference between static and dynamic binding of functions?

1024


What are inline functions? What is the syntax for defining an inline function?

1156


write a corrected statement in c++ so that the statement will work properly. x = y = z + 3a;

1888


What is the arrow operator in c++?

1010


What is a constant reference?

1073


What is polymorphism & list its types in c++?

1057


What is the difference between global int and static int declaration?

1051


Is swift faster than go?

1090