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

Can you overload the operator+ for short integers?

989


What's the most powerful programming language?

988


Can I create my own functions in c++?

1037


Describe the advantages of operator overloading?

986


What do nonglobal variables default to a) auto b) register c) static

1097


Write a program to find the reverse Fibonacci series starting from N.

1161


write a program that withdrawals,deposits,balance check,shows mini statement. (using functions,pointers and arrays)

2292


To what does “event-driven” refer?

1000


What is #include math h in c++?

1024


What are the benefits of operator overloading?

1153


Write about the use of the virtual destructor?

958


What is auto type c++?

1075


what is C++ exceptional handling?

1086


What are manipulators in c++ with example?

1003


Can we specify variable field width in a scanf() format string? If possible how?

1151