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
Why is not a pointer null after calling free? How unsafe is it to use (assign, compare) a pointer value after it is been freed?
Explain the difference between the local variable and global variable in c?
How can I discover how many arguments a function was actually called with?
What is the full form of getch?
Given two strings S1 and S2. Delete from S2 all those characters which occur in S1 also and finally create a clean S2 with the relevant characters deleted.
What is union in c?
Write a code to achieve inter processor communication (mutual exclusion implementation pseudo code)?
What Is The Difference Between Null And Void Pointer?
What is meant by inheritance?
What is a constant?
which of the following is allowed in a "C" arithematic instruction a) [] b) {} c) () d) none of the above
Differentiate between new and malloc(), delete and free() ?
What is the difference between text and binary modes?
develop algorithms to add polynomials (i) in one variable
Explain Basic concepts of C language?