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 you access memory located at a certain address?
write a c program for swapping two strings using pointer
What are dangling pointers in c?
What are the 5 types of organizational structures?
Why & is used in c?
What do you mean by recursion in c?
main() { printf("hello"); fork(); }
What is FIFO?
How can I avoid the abort, retry, fail messages?
Is fortran still used in 2018?
How can you draw circles in C?
What is memcpy() function?
What are the types of i/o functions?
What is the purpose of type declarations?
What are nested functions in c?