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

Why is not a pointer null after calling free? How unsafe is it to use (assign, compare) a pointer value after it is been freed?

1047


Explain the difference between the local variable and global variable in c?

1025


How can I discover how many arguments a function was actually called with?

1019


What is the full form of getch?

1182


Given two strings S1 and S2. Delete from S2 all those characters which occur in S1 also and finally create a clean S2 with the relevant characters deleted.

1355


What is union in c?

1060


Write a code to achieve inter processor communication (mutual exclusion implementation pseudo code)?

1075


What Is The Difference Between Null And Void Pointer?

1156


What is meant by inheritance?

1048


What is a constant?

995


which of the following is allowed in a "C" arithematic instruction a) [] b) {} c) () d) none of the above

1651


Differentiate between new and malloc(), delete and free() ?

1134


What is the difference between text and binary modes?

1126


develop algorithms to add polynomials (i) in one variable

2109


Explain Basic concepts of C language?

1080