Click here to Skip to main content
15,901,122 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
provide code also
Posted
Comments
Kornfeld Eliyahu Peter 30-Jan-14 5:05am    
Have you done anything so far? Show some effort (coding? searching?)! As is i ain't a question...
thatraja 30-Jan-14 5:05am    
We don't spoil student's eduction by giving them code. Besides we don't have any readymade-code.

try google like ^[^]
 
Share this answer
 
 
Share this answer
 
Comments
thatraja 30-Jan-14 5:09am    
Please don't answer these questions, atleast not this way(giving code). No vote from me. :|
Karthik_Mahalingam 30-Jan-14 5:26am    
No Thatraja,
Instead of copy pasting some lines of code from other sites, they can simply refer that site no...
even they will go more information from those links.
i am sorry, if anything wrong...
thatraja 30-Jan-14 5:48am    
No, I said don't give them code(either links or inline-code). Some members're students. You're not supposed to do their homework. They should come with their effort. If not, you should ask to post code(what they have tried) in question. Then we could help them.
Karthik_Mahalingam 30-Jan-14 6:05am    
ok fine. Thanks.
Hai
just google it u can get

C++
int main() { 
 int n, i; 
 scanf("%d", &n); 
 for (i = 2; i<n/2; i++) if (n % i == 0) { printf("Not prime"); return 0; } 
 printf("Prime"); 
 return 0; 


}




A Prime Number can be divided evenly only by 1, or itself.
And it must be a whole number greater than 1.

Example: 5 can only be divided evenly by 1 or 5, so it is a prime number.

But 6 can be divided evenly by 1, 2, 3 and 6 so it is NOT a prime number (it is a composite number).

pls check this link http://www.mathsisfun.com/definitions/prime-number.html[^]
 
Share this answer
 
v2
Here you go - http://en.wikipedia.org/wiki/Prime_number[^].
Try implementing the program on your own.

Hint: Here is the algorithm - http://en.wikibooks.org/wiki/Efficient_Prime_Number_Generating_Algorithms[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900