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

What is implicit conversion/coercion in c++?

1458


Difference between strdup and strcpy?

1210


What are the various situations where a copy constructor is invoked?

1136


Why is main an int?

997


What are proxy objects in c++?

1194


Differentiate between an array and a list?

1185


Explain virtual destructor?

1214


What is the use of setfill in c++?

1080


Can I have a reference as a data member of a class? If yes, then how do I initialise it?

1233


Explain the difference between class and struct in c++?

1049


Do we have to use initialization list in spite of the assignment in constructors?

1007


How should runtime errors be handled in c++?

1156


Describe delete operator?

1101


What is protected inheritance?

1055


Mention the storage classes in c++.

1085