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 / swapnil

/*To check whethere Entered no. is PRIME or NOT*/
#include<iostream.h>
#include<conio.h>
main()
{
int num,i;
clrscr();
cout<<"Enter the any no.="<<"\n";
cin>>num;
for(i=2;i<=num;i++)
{
if(num%i==0)
{
break;
}
}
if(i==num)
{
cout<<"The number entered is a
PRIME no.";
}
else
{
cout<<"The number entered is NOT a
PRIME no.";
}
getch();
}

Is This Answer Correct ?    74 Yes 41 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Does c++ have foreach?

995


What is singleton class in c++?

1005


What are the various oops concepts in c++?

984


the first character in the variable name must be an a) special symbol b) number c) alphabet

1050


Describe friend function & its advantages.

1104


What is pure virtual function?

1026


Discuss the effects occur, after an exception thrown by a member function is unspecified by an exception specification?

1026


Are vectors faster than arrays?

963


the maximum length of a character constant can be a) 2 b) 1 c) 8

1049


what is oops and list its features in c++?

1003


What is array in c++ pdf?

1108


Tell me can a pure virtual function have an implementation?

981


Which of the following is not a valid declaration for main() a) int main() b) int main(int argc, char *argv[]) c) They both work

1025


How many namespaces are there in c++?

1017


which operator is used for performing an exponential operation a) > b) ^ c) none

1000