need real newbie help (operators)

This is a discussion on need real newbie help (operators) within the C Programming forums, part of the General Programming Boards category; i have to use +=,-=,/= or *= for this: c=3-c; please help me i hope this explains everything to you, ...

  1. #1
    Registered User
    Join Date
    Aug 2002
    Posts
    2

    Question need real newbie help (operators)

    i have to use +=,-=,/= or *= for this:

    c=3-c;

    please help me

    i hope this explains everything to you, as my english is not that good

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,422
    Well if you had

    c = c - 3;

    The short form would be
    c -= 3;

    I don't think there is a shortened form for c=3-c;

  3. #3
    Registered User
    Join Date
    Aug 2002
    Posts
    2
    i also think there is no way, but my "so called" teacher gave me this from a c-examples book.

    the 1st example was:

    x = x+1 --> x+=1

    the 2nd:

    a = a-8 --> a-=8

    the 3rd:

    c = 3-c --> ????????

    he also wants that nobody helps me at the place where i am right now, so i decided to write to this board

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,422
    Well there is no single statement way to achieve it

    But there is a dumb two statement way
    c *= -1;
    c += 3;

  5. #5
    Blank
    Join Date
    Aug 2001
    Posts
    1,034
    Code:
    c *= -1, c += 3;
    This uses the comma sequencer operator.
    I'm pretty sure this one or the last one should be good enough for your assignment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Newbie with C++ NOT, OR, AND operators question...
    By JiWiz in forum C++ Programming
    Replies: 4
    Last Post: 07-27-2008, 11:05 AM
  2. %16 with double
    By spank in forum C Programming
    Replies: 11
    Last Post: 03-05-2006, 09:10 PM
  3. Real newbie in need of help
    By TheDarKinG in forum C++ Programming
    Replies: 23
    Last Post: 07-29-2002, 09:51 AM
  4. Programming Puns
    By kermi3 in forum A Brief History of Cprogramming.com
    Replies: 44
    Last Post: 03-23-2002, 03:38 PM
  5. Real newbie with VC6 questions
    By MagiZedd in forum Windows Programming
    Replies: 8
    Last Post: 10-15-2001, 08:27 PM

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