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


Please Help Members By Posting Answers For Below Questions

Explain how can you be sure that a program follows the ansi c standard?

1164


How can I read in an object file and jump to locations in it?

824


What is the size of enum in bytes?

825


How can I call a function with an argument list built up at run time?

949


if the area was hit by a virus and so the decrease in the population because of death was x/3 and the migration from other places increased a population by 2x then annually it had so many ppl. find our the population in the starting.

4875


Explain what does the characters 'r' and 'w' mean when writing programs that will make use of files?

1041


How can I recover the file name given an open stream?

786


Explain b+ tree?

851


Explain what are bus errors, memory faults, and core dumps?

1045


Write a function which takes as parameters one regular expression(only ? and * are the special characters) and a string and returns whether the string matched the regular expression.

881


What is the hardest programming language?

923


What is wild pointer in c with example?

824


What is the difference between struct and typedef struct in c?

919


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

1044


How to implement a packet in C

2642