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
What do you mean by dynamic memory allocation in c? What functions are used?
What are the types of arrays in c?
What is the function of this pointer?
Explain modulus operator.
What is the difference between break and continue?
process by which one bit patten in to another by bit wise operation is? (a) masking, (b) pruning, (c) biting, (d) chopping,
Explain how can I remove the trailing spaces from a string?
WHAT IS THE DEFINATION OF IN TECHNOLOGY AND OFF TECHNOLOGY ?
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
Why isn't any of this standardized in c? Any real program has to do some of these things.
What is the purpose of void pointer?
why we wont use '&' sing in aceesing the string using scanf
What are the 4 types of unions?
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
can anyone please tell about the nested interrupts?