write the program for prime numbers?
Answer Posted / jassneet anand
import java.*;
class prime
{
public static void main(String args[])
{
int number=__;//"you wish to check ";
int flag=0;
for(i=2;i<=(int)(Math.sqrt(number));i++)
{
if(number%i==0)
{
System.out.println("Not a Prime Number");
flag=1;
break;
}
}
if(flag==0)
System.out.println("Prime Number");
}
}
Is This Answer Correct ? | 12 Yes | 9 No |
Post New Answer View All Answers
Give a one-line C expression to test whether a number is a power of 2. [No loops allowed - it's a simple test.]
how to write optimum code to divide a 50 digit number with a 25 digit number??
Why do we use & in c?
Which is best book for data structures in c?
What are the preprocessor categories?
What is the mean of function?
What is data structure in c programming?
please send me the code for multiplying sparse matrix using c
What is the difference between near, far and huge pointers?
Is return a keyword in c?
Is that possible to add pointers to each other?
Explain the difference between ++u and u++?
Tell me about low level programming languages.
Explain what is operator promotion?
c programs are converted into machine language with the help of a) an interpreter b) a compiler c) an operatinf system d) none of the above