Thread: is this C++ code sample?

  1. #1
    Registered User
    Join Date
    Feb 2006
    Posts
    22

    is this C++ code sample?

    average sum = (average 1 + average 2)/2

  2. #2
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    Nope. Even if average was typedef'd, 1 and 2 aren't legal identifiers and you can't just sum these newly declared variables. Also the statement is missing a semicolon at the end.

    If you're just simply talking in generics, than that's sample code for about any program language you can think of.
    Last edited by SlyMaelstrom; 03-03-2006 at 02:05 PM.
    Sent from my iPadŽ

  3. #3
    Registered User
    Join Date
    Feb 2006
    Posts
    22
    oh...so its not goin' to work..what can i do to make it a code....

  4. #4
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    You can start by actually learning C++ from a book rather than just kinda guessing...
    Sent from my iPadŽ

  5. #5
    Registered User
    Join Date
    Feb 2006
    Posts
    22
    exam average = ( exam_1 + exam_2)/2;

  6. #6
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    Sure, that could *possibly* be legal C++. But do you know how to make it legal? I would guess no.
    Sent from my iPadŽ

  7. #7
    Registered User
    Join Date
    Feb 2006
    Posts
    22
    no....not reallie...i have a book ..but it doesn't exam much


    fahrenheit - 9/5 centgrade +32 ....is dat correct code

  8. #8
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    Please stop guessing and get a real book.
    Sent from my iPadŽ

  9. #9
    Registered User
    Join Date
    Feb 2006
    Posts
    22
    thanks for ur help man....

  10. #10
    Slave MadCow257's Avatar
    Join Date
    Jan 2005
    Posts
    735
    Don't give that sarcasm. There are some really helpful and smart people on this board...you just asked a bad question

    http://www.catb.org/~esr/faqs/smart-questions.html

  11. #11
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    Quote Originally Posted by MadCow257
    Don't give that sarcasm. There are some really helpful and smart people on this board...
    Yeah, seriously... not everyone is like me.
    Sent from my iPadŽ

  12. #12
    Registered User
    Join Date
    Feb 2006
    Posts
    22
    one more thing..

    whats ++3.14?

  13. #13
    Registered User
    Join Date
    Feb 2006
    Posts
    22
    u add 3. 14 twice

  14. #14
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    No, you can't increment a constant.

    Code:
    ++var1;
    would add 1 to whatever var1's value was.
    Sent from my iPadŽ

  15. #15
    Registered User mrafcho001's Avatar
    Join Date
    Jan 2005
    Posts
    483
    the ++ is only used with variables. and it increments their values by one.

    ++ is really += 1
    My Website
    010000110010101100101011
    Add Color To Your Code!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Pre-Interviewer asking sample code
    By jayee_spicyguy in forum C Programming
    Replies: 3
    Last Post: 02-09-2009, 11:21 AM
  2. Quick help on bool or while? Sample code...
    By Striph in forum C Programming
    Replies: 5
    Last Post: 01-12-2006, 04:05 PM
  3. True ASM vs. Fake ASM ????
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 04-02-2003, 04:28 AM
  4. stricmp() where can I view the sample code?
    By Unregistered in forum C Programming
    Replies: 5
    Last Post: 06-28-2002, 08:40 AM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM