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 / tuhin pal chowdhury

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
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;
getch();
}

Is This Answer Correct ?    1 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are pointers used for c++?

1007


What is c++ namespace?

1143


What is c++ prototype?

1080


What is do..while loops structure?

1084


What is java and c++?

1098


What are member functions used in c++?

1073


What is enum class in c++?

1179


What is the basic structure of c++ program?

1032


Which sort is best for the set: 1 2 3 5 4 a) Quick Sort b) Bubble Sort c) Merge Sort

1007


Which c++ compiler is best?

1095


How is new() different from malloc()?

1063


What is dynamic and static typing?

1134


Is it possible for a member function to delete the pointer, named this?

1085


Describe the setting up of my member functions to avoid overriding by the derived class?

1070


Define namespace in c++?

998