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...

check whether a no is prime or not.

Answer Posted / m.shanmuga sundaram,rjnsoftwar

void main()
{
int primeNo;
int i;
bool isPrime = false;

printf("Enter a number to check prime or not\n");
scanf("%d",&primeNo);

for(i = 2; i <= primeNo / 2; i++)
{
if(primeNo % i == 0)
{
isPrime = true;
break;
}
}

if(isPrime)
printf("The number is a prime number %
d\n",primeNo);
else
printf("The number is not a prime number %
d\n",primeNo);
}

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Should a constructor be public or private?

1022


What does getch() do according to the ANSI C++ standard a) Reads in a character b) Checks the keyboard buffer c) Nothing in particular (Its not defined there)

1041


Differentiate between an external iterator and an internal iterator? What is the advantage of an external iterator.

1035


What kind of jobs can I get with c++?

1101


Is atoi safe?

1046


What is srand c++?

1095


What flag means?

940


What is meant by forward referencing and when should it be used?

1004


Can notepad ++ run c++?

1068


Is c++ an oop?

1078


Is facebook written in c++?

988


What is code reusability in c++?

1236


Explain how the virtual base class is different from the conventional base classes of the opps.

1150


How do I use turbo c++?

977


Explain abstraction.

1100