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

How would you find out if a linked-list is a cycle or not?

1009


How do you add an element to a set in c++?

999


How can you quickly find the number of elements stored in a dynamic array? Why is it difficult to store linked list in an array?

1039


Explain virtual class?

1037


Does c++ have arraylist?

1028


Explain what are mutator methods in c++?

1119


Should a constructor be public or private?

1037


Describe the role of the c++ in the tradeoff of safety vs. Usability?

1218


What is private, public and protected inheritance?

1090


Define pre-condition and post-condition to a member function in c++?

1153


What flag means?

961


Mention the ways in which parameterized can be invoked.

933


What is an operator in c++?

1068


What is the use of class in c++?

1086


Why should you learn c++?

1026