printing only prime numbers

This is a discussion on printing only prime numbers within the C Programming forums, part of the General Programming Boards category; >If s/he pastes the code and run it - which they will have to do - the code will not ...

  1. #16
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >If s/he pastes the code and run it - which they will have to do - the code will not only be easier to read
    It's still poorly formatted when I cut and paste into my text editor.
    My best code is written with the delete key.

  2. #17
    Registered User caroundw5h's Avatar
    Join Date
    Oct 2003
    Posts
    751
    Quote Originally Posted by Prelude
    >If s/he pastes the code and run it - which they will have to do - the code will not only be easier to read
    It's still poorly formatted when I cut and paste into my text editor.
    u suck!!

  3. #18
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    Quote Originally Posted by caroundw5h
    u suck!!
    Occasionally.
    My best code is written with the delete key.

  4. #19
    Registered User Micko's Avatar
    Join Date
    Nov 2003
    Posts
    712
    Listen , my intention was not to underestimate anyone's work.
    Like I said I have solved my problem and post code. If 1 is really prime number or not is arguable. For someone it is and for someone it is not. However I never past my homework and ask you to do it. I paste code only and only if I did't manage to do it myself or didn't have time to bother. n*pair (n integer) of eyes can see some that I can't at the moment.
    I find this board very usefull and didn't want to disprage anyone, but I am surprise with the fact that all this discussion about number 1. Anyway I would left it to mathematicians to agree.
    Cheers!!!!!!!!

  5. #20
    Registered User caroundw5h's Avatar
    Join Date
    Oct 2003
    Posts
    751
    don't think too highly about this. no one is disparaging anyone's work. We critique and give constructive suggestions and we learn from each others work. if an individual doesn't, they stagnate.

    as to whether 1 is a prime number or not. read linuxdude's post. if you can't listen, you prlly can't learn either.

  6. #21
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >but I am surprise with the fact that all this discussion about number 1
    We're a community of pedants. Those that aren't tend not to stick around for long periods of time.

    >For someone it is
    Anyone who believes the mathematical definition of a prime number.

    >and for someone it is not
    Anyone who doesn't.
    My best code is written with the delete key.

  7. #22
    Registered User Micko's Avatar
    Join Date
    Nov 2003
    Posts
    712

  8. #23
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    Quote Originally Posted by Prelude
    Occasionally.
    Whoa! Please tell me that has another meaning than the one my sick mind gave it...
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  9. #24
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    X^2 is a perv, wait I had the same thought. Hmm But I'm exempt from that status

    Micko: There are a lot of things you'll be asked, as a programming student, to do that aren't "correct." Do them, get the grade, realize your instructor is wrong, and move on

  10. #25
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Thantos
    Do them, get the grade, realize your instructor is wrong, and move on
    Better yet:

    1) Do them.
    2) Add comment blocks that quote things like the standard, and the like, proving they're wrong.
    Code:
    int main( void )
    {
        char buf[80] = {0};
    
        printf("Enter a line: ");
        /* Get a line from the user:
         * NOTE: One should NEVER use gets, because it is horribly 
         * unsafe, and prone to buffer overflows. But, since I'm left 
         * with no other choice, I will be forced to use it. However,
         * be aware that if you crash this program when testing it for
         * my grade, it's your own fault, since I'd use fgets, but you
         * won't let me.
         */
        gets( buf );
    
        return 0;
    }
    I'm sure they'd appreciate the constructive criticism.

    Quzah.
    Hope is the first step on the road to disappointment.

  11. #26
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Heh I actually told my instructor that I did not have the ability to type "void main()" and that my fingers would instead type "int main()".

  12. #27
    Registered User linuxdude's Avatar
    Join Date
    Mar 2003
    Location
    Louisiana
    Posts
    926
    better yet
    Code:
    int main(void)

  13. #28
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Yes of course
    Oh and adding a copyright notice to the top of the code is always fun also. I also thought (but didn't) about using winzip's password feature on my files.

    What really sucked was having to put a comment on every closing }. Most of them were nothing more than /* End of if statement */ and the like

  14. #29
    CS Author and Instructor
    Join Date
    Sep 2002
    Posts
    511

    Smile

    Quote:
    Originally Posted by Thantos
    Do them, get the grade, realize your instructor is wrong, and move on

    Better yet:

    1) Do them.
    2) Add comment blocks that quote things like the standard, and the like, proving they're wrong.
    Code:
    int main( void )
    {
    char buf[80] = {0};

    printf("Enter a line: ");
    /* Get a line from the user:
    * NOTE: One should NEVER use gets, because it is horribly
    * unsafe, and prone to buffer overflows. But, since I'm left
    * with no other choice, I will be forced to use it. However,
    * be aware that if you crash this program when testing it for
    * my grade, it's your own fault, since I'd use fgets, but you
    * won't let me.
    */
    gets( buf );

    return 0;
    }
    I'm sure they'd appreciate the constructive criticism.

    Quzah.
    Well I have had many "so called experts"- in both my C and Java classes in the past. I usually tell my students if they want to challenge me about various coding issues- prove their answer in writing and cite were they found their sources. Then and only then I will consider changing anything.

    I usually find in most cases students:
    1. cant back up their claims
    2. can't follow directions on a given assignment
    3. love to "whine" about their grades

    I am sure glad I don't have some of you in my programming classes!!!

    Quzah, have you ever thought about teaching??
    Last edited by Mister C; 06-10-2004 at 10:56 PM.
    Mr. C: Author and Instructor

  15. #30
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    And there are plenty of "so called experts" teaching. In classes where there is wiggle room for what is "right" and what is "wrong" I prefer to figure out what the instructor wants and give them that even if I don't agree with it. Heck half of my answers for my tutor training class were nothing more then lip service. I wasn't about to go "I think this idea is a crock." Same applies to my programming classes. If the instructor wants a global variable then I'll use the global variable. I'm still going to use the best techniques I know in my personal projects but I want the dang A

    Number 2 is the truth. But you also have to add in: Can only follow step by step instructions and only if given in the smallest steps.

    We had one assignment which was to randomily place queens on a 4x4 chessboard until there were no open safe spots left. He wrote out the method out on the board and gave the simplist method to use. I still had people coming in for tutoring that needed hand holding to figure out what to do.

Page 2 of 3 FirstFirst 123 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Prime Numbers
    By Ahmed29 in forum C++ Programming
    Replies: 7
    Last Post: 11-09-2008, 10:54 AM
  2. Checking very large prime numbers
    By password in forum C++ Programming
    Replies: 2
    Last Post: 02-11-2008, 12:26 PM
  3. Prime Numbers
    By EdSquareCat in forum C++ Programming
    Replies: 9
    Last Post: 05-29-2007, 06:54 PM
  4. prime numbers code compile error
    By Tony654321 in forum C Programming
    Replies: 5
    Last Post: 10-10-2004, 11:13 AM
  5. prime numbers
    By Unregistered in forum C Programming
    Replies: 17
    Last Post: 08-20-2002, 09:57 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21