Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 are the types of type qualifiers in c?

1091


Write an algorithm for implementing insertion and deletion operations in a singly linked list using arrays ?

3522


What does node * mean?

1232


What is a null string in c?

1047


explain what is fifo?

1078


What is main () in c?

1076


Tell me the use of bit field in c language?

1071


pgm to find any error in linklist(in single linklist check whether any node points any of previous nodes instead of next node)

2646


What is a void pointer in c?

1111


What are pointers? What are different types of pointers?

1149


What is new line escape sequence?

1357


Tell me about low level programming languages.

1134


What is variables in c?

1054


the 'sizeof' operator reported a larger size than the calculated size for a structure type. What could be the reason?

1003


Why do we use c for the speed of light?

1214