is this C++ code sample?

This is a discussion on is this C++ code sample? within the C++ Programming forums, part of the General Programming Boards category; average sum = (average 1 + average 2)/2...

  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,074
    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 01: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,074
    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,074
    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,074
    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,074
    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,074
    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!

Page 1 of 2 12 LastLast
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, 10:21 AM
  2. Quick help on bool or while? Sample code...
    By Striph in forum C Programming
    Replies: 5
    Last Post: 01-12-2006, 03: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, 03: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

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