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 program for prime numbers?

Answer Posted / mamoon

#include<iostream.h>
#include <math.h>

void main()
{
int number;
cout<<" --------------------------------------------
-"<<endl;
cout<<" Enter a number to find if its a prime
number "<<endl;
cout<<" --------------------------------------------
-"<<endl;
cin>>number;
bool a =true;

for(int i=2;i<sqrt(number);i++) //check
untill the square root
{

if(number%i==0) // if it is
divisible it is non prime
{
a=false;
break;
}
}


if(a==false)
cout<<number<<" \nis not a prime number"<<endl;
else
cout<<number<<" \nis a prime number"<<endl;

}

Is This Answer Correct ?    0 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What do you mean by dynamic memory allocation in c? What functions are used?

1104


What are the types of arrays in c?

1094


What is the function of this pointer?

1218


Explain modulus operator.

993


What is the difference between break and continue?

1386


process by which one bit patten in to another by bit wise operation is? (a) masking, (b) pruning, (c) biting, (d) chopping,

2356


Explain how can I remove the trailing spaces from a string?

990


WHAT IS THE DEFINATION OF IN TECHNOLOGY AND OFF TECHNOLOGY ?

2333


A text file that contains declarations used by a group of functions,programs,or users a) executable file b) header file c) obj file d) .cfile

1048


Why isn't any of this standardized in c? Any real program has to do some of these things.

1146


What is the purpose of void pointer?

985


why we wont use '&' sing in aceesing the string using scanf

2308


What are the 4 types of unions?

986


Iam a B.Tech graduate and completed my engineering in 2009, from 2005 to 2009 and after that i had done nothing.Now i want to do job and get into BPO field . Friends give me suggestions as what to say in interview... if they ask me that what would you had done ... these many years without doing job ??????? pls urgent

1772


can anyone please tell about the nested interrupts?

2063