i 'm trying to make this program of a prime number in c language but ive not been able to do so,can any 1 of u plz help me out...i want to do 2 things...
1)First,test whether a number is prime or not
2)generate the series of all the prime numbers till the limit of that number...for example..i want to test whther a number 16 is prime or not and then print all the series of prime numbers upto 16....how can i do this...any help would be much appreciated ...hope any1 can write the code so that i can understand,by looking at that, :cry:
Thx.
galmca
0
Light Poster
Recommended Answers
Jump to PostIf you look at the part called Similar Threads at the bottom of this webpage you will find a lot of threads with examples.
Jump to PostIt is easy..
For each number from 2 to TheSpecificNumber If number is a prime number Print number Else Dont Print it End if End For
Jump to Postan easy solution is:
startX, endX; for(i=startX; i<=endX; i++) { for(j=2; j<i; j++) { p=i%j; if(p!=0) { // you know it is not prime... break the loop } //now get the prime number when p==0 after checking all the values for j. } // once u got …
Jump to PostGet rid of
void main
- it's not standard. While you're at it, you can trash the old crappy headerconio.h
, and start using code tags. Thanks.
Jump to Postthis is an old post? my mistake. Just ignore my reply...
All 21 Replies
WolfPack
491
Posting Virtuoso
Team Colleague
galmca
0
Light Poster
WolfPack
491
Posting Virtuoso
Team Colleague
galmca
0
Light Poster
orko
36
Junior Poster
fearfact_53
0
Newbie Poster
John A
1,896
Vampirical Lurker
Team Colleague
abhinav.sharma
0
Newbie Poster
towhidd
0
Newbie Poster
VernonDozier
2,218
Posting Expert
Featured Poster
Duoas
1,025
Postaholic
Featured Poster
pradeepchhetri
-1
Newbie Poster
Hiroshe
commented:
Bad code, old thread
-1
yellowSnow
commented:
Your code brings tears to my eyes and not in a good way.
+0
Hiroshe
499
Posting Whiz in Training
Arindam_joy
0
Newbie Poster
Banfa
597
Posting Pro
Featured Poster
invisal
381
Search and Destroy
cupofdenial
0
Newbie Poster
tayyab569
0
Newbie Poster
hakibam
22
Newbie Poster
hakibam
22
Newbie Poster
Narue
commented:
Grats for noticing the date (belated or not) and apologising. :)
+22
ramesh thota
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.