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 an incomplete type in c++?

1220


How would you use qsort() function to sort an array of structures?

1072


Am pass the 10000 records to target in target I will take commit interval 15000 when I was stop the work flow what will happened

1518


Explain about Virtual Function in C++?

979


What is a tree in c++?

924


What is cin clear () in c++?

1140


Array base access faster or pointer base access is faster?

2251


Which sort does c++ use?

979


What is different in C++, compare with unix?

1024


How many types of classes are there in c++?

991


Write a program using shift_half( ) function to shift the elements of first half array to second half and vice versa.

1281


Is rust better than c++?

1066


What are the advantage of using register variables?

1125


What flag means?

900


What is the sequence of destruction of local objects?

930