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

How can you access memory located at a certain address?

870


write a c program for swapping two strings using pointer

2329


What are dangling pointers in c?

837


What are the 5 types of organizational structures?

781


Why & is used in c?

926


What do you mean by recursion in c?

863


main() { printf("hello"); fork(); }

952


What is FIFO?

1152


How can I avoid the abort, retry, fail messages?

870


Is fortran still used in 2018?

802


How can you draw circles in C?

857


What is memcpy() function?

851


What are the types of i/o functions?

974


What is the purpose of type declarations?

886


What are nested functions in c?

785