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 / rajan maheshwari

#include<iostream.h>
#include<conio.h>
void main()
{clrscr();
int a,c=0,i=2;
cout<<"Enter A Number = ";
cin>>a;
while(i<=a/2)
{
if(a%i==0)
{c=0;
break;}
else
{i++;
c=1;
}}
if(c==1||a==2||a==3)
cout<<"\nPrime Number";
else
if(a==1)
cout<<"\nNeither Prime Nor Composite";
else
cout<<"\nNot a Prime Number";
getch();
}

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a .lib file in c++?

1046


Is java based off c++?

1028


Is dev c++ free?

1101


How can you quickly find the number of elements stored in a dynamic array?

1095


What is a singleton class c++?

1093


Explain what data encapsulation is in c++?

1155


Why c++ is faster than java?

1107


what does the following statement mean? int (*a)[4]

1138


What is ios :: in in c++?

1112


How much do coding jobs pay?

1060


Why is c++ still popular?

1099


Write a program to find the Fibonacci series recursively.

1114


Explain terminate() and unexpected() function?

1165


What is the difference between reference and pointer?

1226


Differentiate between a copy constructor and an overloaded assignment operator.

1140