Print Prime Numbers(using for loop)

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Sep 2009
Posts: 1
Reputation: nitin_mehta has a little shameless behaviour in the past 
Solved Threads: 0
nitin_mehta nitin_mehta is offline Offline
Newbie Poster

Re: Print Prime Numbers(using for loop)

 
-2
  #31
Sep 3rd, 2009
  1. #include<stdio.h>
  2. void main()
  3. int i,j,prime;
  4. for(i=2;i<=500;i++)
  5. for(j=2;j<500;j++)
  6. {
  7. if(i%j=o)
  8. {
  9. prime=0;
  10. break;
  11. }
  12. prime=1;
  13. if(prime)
  14. {
  15. printf("\n%d",i);
  16. }
  17. }
  18. }
Last edited by ~s.o.s~; Sep 4th, 2009 at 12:09 am. Reason: Added code tags, please learn to use them.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for C
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC