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

What is the meaning of ?

626


What does emoji p mean?

610


What is the use of c language in real life?

536


Write a program to print factorial of given number using recursion?

607


How can I swap two values without using a temporary?

621






How reliable are floating-point comparisons?

632


Which is better pointer or array?

606


What is mean by Data Driven framework in QTP? Can any one answer me in details on this regard.

1788


What is a char in c?

559


Why is c known as a mother language?

751


Write a progarm to find the length of string using switch case?

1616


What is a good data structure to use for storing lines of text?

604


What is console in c language?

616


What are the 5 types of inheritance in c ++?

591


What is the use of getchar() function?

634