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 this weird colon-member (" : ") syntax in the constructor?

1029


Explain the difference between using macro and inline functions?

1128


Is c++ the hardest language?

991


Function can be overloaded based on the parameter which is a value or a reference. Explain if the statement is true.

1123


Describe about storage allocation and scope of global, extern, static, local and register variables?

1259


Which software is best for c++ programming?

1053


Write a program to add three numbers in C++ utilizing classes.

1120


what is C++ objects?

1198


Define a nested class.

1083


Is the declaration of a class its interface or its implementation?

1176


What does it mean to declare a member function as virtual?

1077


How do we balance an AVL Tree in C++?

1134


Explain "const" reference arguments in function?

1066


How do you establish a has-a relationship?

1115


You have two pairs: new() and delete() and another pair : alloc() and free(). Explain differences between eg. New() and malloc()

1162