Shorten Statements are WRONG?!

This is a discussion on Shorten Statements are WRONG?! within the C++ Programming forums, part of the General Programming Boards category; Ok i had a program for computer science. You take in a persons weight, a planet letter, and convert to ...

  1. #1
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331

    Shorten Statements are WRONG?!

    Ok i had a program for computer science. You take in a persons weight, a planet letter, and convert to how much they would weigh on that planet. the conversion everyone else used, say for jupiter, looked like this:

    weight = weight * 0.88;

    Which she gave 100's for (my teacher) i got ten points off for each time i did mine like this:

    weight *= 0.88;

    WTF?! I thought that was BETTER and more effecient, why would she give me points off?! And yea she went over this, but never said don't use it WTH?!

  2. #2
    Registered User The Dog's Avatar
    Join Date
    May 2002
    Location
    Cape Town
    Posts
    788
    >> why would she give me points off?!

    'cos she's dumb!

  3. #3
    Code Monkey Davros's Avatar
    Join Date
    Jun 2002
    Posts
    812
    Well actually, Jupiter's gravity is approx. 10 - 12 times that of Earth, at it's [approximate] surface.

    Therefore, to get your weight on Jupiter you should write:

    weight = wieght * 10;

    or if you like

    weight *= 10;

  4. #4
    Registered User
    Join Date
    Oct 2002
    Posts
    32
    wouldn't it be better to ask your teacher?

  5. #5
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    she made up the #'s davros :P

    >>wouldn't it be better to ask your teacher?

    I did, she told me it was a bad practice.....i'm not c++ god in any respect, but i have to disagree.

  6. #6
    Code Monkey Davros's Avatar
    Join Date
    Jun 2002
    Posts
    812

    Talking

    >she made up the #'s davros :P

    Oop. Sorry for being a smart-ass. I'm just bored.

    May be that's also why you lost ten points.
    OS: Windows XP
    Compilers: MinGW (Code::Blocks), BCB 5

    BigAngryDog.com

  7. #7
    BMJ
    BMJ is offline
    Banal internet user BMJ's Avatar
    Join Date
    Aug 2002
    Location
    Chicagoland
    Posts
    1,380
    disassemble "weight = weight * .88;" and "weight *= .88;" and show them to her!

  8. #8
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    Tell her to learn c++ herself!
    A good starting point for her as she obviously knows the syntax but not the use of c++ would be scott meyers effective series.

    Point her to More effective c++ item number 22 : Consider using op= rather than op.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  9. #9
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Your teacher doesn't know what she's talking about. Bad practice?

    You may quote me. Yes, tell her to learn C++, or perhaps start with C first.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  10. #10
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    And from what i've seen, I HIGHLY doubt your teacher knows anything close to what Stoned_Coder, Sang-drax or Davros does.

    Style is... well just that, style. I can't see any competent teacher taking off points for something which gets the job done just as efficiently, and is as (if not more) readable.

    if (!strcmp(string1, string2)) is not "preferred"
    if (strcmp(string1, string2) == 0) is, but it really doesn't matter.

  11. #11
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    I bet she includes <iostream.h>
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  12. #12
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    yea well the iostream header file is kinda needed there dude :P

  13. #13
    ˇAmo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136
    int main?? Why are you returning an int from main? It only wastes time.

    Seriously though, as for your teacher, POLITELY ask her to get a second opinion. If she refuses to, go to the next person in the chain of command at your school.

  14. #14
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    I may ask to talk to her after class about it, i don't want her feeling that i am challenging her with the students to see...

    as for main, my preference is

    int main()
    {
    ......
    return 0;
    }

  15. #15
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    If this is a C++ class, not just a general programming class, that's scary ...

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Unknown memory leak with linked lists...
    By RaDeuX in forum C Programming
    Replies: 6
    Last Post: 12-07-2008, 04:09 AM
  2. newbie question - if statements without conditions
    By c_h in forum C++ Programming
    Replies: 2
    Last Post: 07-18-2008, 11:42 AM
  3. Efficiency of case statements
    By Yasir_Malik in forum C Programming
    Replies: 26
    Last Post: 05-23-2006, 12:36 PM
  4. God
    By datainjector in forum A Brief History of Cprogramming.com
    Replies: 746
    Last Post: 12-22-2002, 12:01 PM
  5. whats wrong with my if statements
    By ssjnamek in forum C++ Programming
    Replies: 8
    Last Post: 01-29-2002, 12:48 AM

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