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
What is the use of a conditional inclusion statement in C?
Why doesnt this code work?
How can you increase the allowable number of simultaneously open files?
explain what is a newline escape sequence?
Differentiate between new and malloc(), delete and free() ?
What are the restrictions of a modulus operator?
Given a valid 24 hour format time find the combination of the value and write a program ,do not hard the value and if any other inputs provided should work with the logic implemented Input: 11:30 Output: 13:10 Input: 18:25 Output: 21:58
Explain what is #line used for?
How can you find the exact size of a data type in c?
Describe the complexity of Binary search, Quicksort and various other sorting and searching techniques..
Program to find the sum of digits of a given number until the sum becomes a single digit. (e.g. 12345=>1+2+3+4+5=15=>1+5=6)
When the macros gets expanded?
Explain bit masking in c?
Why is c known as a mother language?
a c variable cannot start with a) an alphabet b) a number c) a special symbol d) both b and c above