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
How can I read in an object file and jump to locations in it?
What is character constants?
what is the function of pragma directive in c?
difference between object file and executable file
diff between exptected result and requirement?
Why c is a procedural language?
What is the explanation for the dangling pointer in c?
what is the format specifier for printing a pointer value?
How many bytes are occupied by near, far and huge pointers (dos)?
What is calloc() function?
What are the advantages and disadvantages of a heap?
What is data types?
What are global variables and explain how do you declare them?
GIven a sequence of characters. How will you convert the lower case characters to upper case characters. ( Try using bit vector - sol given in the C lib -> typec.h)
Where static variables are stored in c?