Thread: IQOD #3

Page 2 of 2 FirstFirst 12
Results 16 to 24 of 24
  1. #16
    Hell_Demon's Avatar
    Join Date
    Mar 2008
    Gender
    male
    Location
    I love causing havoc
    Posts
    3,976
    Reputation
    343
    Thanks
    4,320
    My Mood
    Cheeky
    Quote Originally Posted by lalakijilp View Post
    hoeland duurt het voordat je de basis goed hebt?
    maandje ofzo, en dan moet je nog met de basis van hacken beginnen ;p

  2. #17
    why06's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    IBM
    Posts
    4,304
    Reputation
    170
    Thanks
    2,203
    My Mood
    Flirty
    Ok since everyone else already answered I'm just going to guess that "a+1" sends a decimal value instead of a octal or hex value and so some garbage value would be printed and then another garbage value.

    EDIT:
    Hmm guess not must do some automatic type conversion.
    Last edited by why06; 09-19-2009 at 07:17 AM.

    "Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."
    - Dwight D. Eisenhower

  3. #18
    zhaoyun333's Avatar
    Join Date
    Apr 2009
    Gender
    male
    Posts
    396
    Reputation
    11
    Thanks
    1,125
    a is an array if you outputed it will give you the address in the memory of the array. Say a is 0x42313 then (a+1) is 0x42314 but *(a+1) would give you the value in the memory which would be 2.
    There are five possible operations for any army. If you can fight, fight; if you cannot fight, defend; if you cannot defend, flee; if you cannot flee, surrender; if you cannot surrender, die." - Sima Yi

  4. #19
    why06's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    IBM
    Posts
    4,304
    Reputation
    170
    Thanks
    2,203
    My Mood
    Flirty
    Quote Originally Posted by zhaoyun333 View Post
    a is an array if you outputed it will give you the address in the memory of the array. Say a is 0x42313 then (a+1) is 0x42314 but *(a+1) would give you the value in the memory which would be 2.
    Oh. I see I thought it would do something weird like 0x42314 + 1 = 0x42315 but since the array points to int values it would actually need to be + 16 or +32 depending if it was a short or long in value. So that if you pointed to this address you would just get some garbage value because its not a whole int.

    "Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."
    - Dwight D. Eisenhower

  5. #20
    Hell_Demon's Avatar
    Join Date
    Mar 2008
    Gender
    male
    Location
    I love causing havoc
    Posts
    3,976
    Reputation
    343
    Thanks
    4,320
    My Mood
    Cheeky
    Quote Originally Posted by why06 View Post
    Ok since everyone else already answered I'm just going to guess that "a+1" sends a decimal value instead of a octal or hex value and so some garbage value would be printed and then another garbage value.

    EDIT:
    Hmm guess not must do some automatic type conversion.
    Your answer is: incorrect

    Quote Originally Posted by why06 View Post
    Oh. I see I thought it would do something weird like 0x42314 + 1 = 0x42315 but since the array points to int values it would actually need to be + 16 or +32 depending if it was a short or long in value. So that if you pointed to this address you would just get some garbage value because its not a whole int.
    size of an int is 4, so if a is at 0x42314, a+1 would be 0x42318

  6. #21
    zeco's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    Canada
    Posts
    683
    Reputation
    12
    Thanks
    78
    My Mood
    Cynical
    Quote Originally Posted by Hell_Demon View Post
    starting with my 7th year on 5th of october, i got a C++ book with which i started when i turned 10
    An answer like that assumes i know how old you are =)

  7. #22
    Hell_Demon's Avatar
    Join Date
    Mar 2008
    Gender
    male
    Location
    I love causing havoc
    Posts
    3,976
    Reputation
    343
    Thanks
    4,320
    My Mood
    Cheeky
    Quote Originally Posted by zeco View Post
    An answer like that assumes i know how old you are =)
    starting with my 7th year on the 5th of october, i started coding when i turned 10. is my logic wrong or does that mean i turn 17 the 5th of october(and it being my 7th year in C++)

  8. #23
    zeco's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    Canada
    Posts
    683
    Reputation
    12
    Thanks
    78
    My Mood
    Cynical
    Quote Originally Posted by Hell_Demon View Post
    starting with my 7th year on the 5th of october, i started coding when i turned 10. is my logic wrong or does that mean i turn 17 the 5th of october(and it being my 7th year in C++)
    And here in lies the problem. I thought by 7th year, you meant your grade or something :/

    And haha, you got a c++ book for your birthday? Lucky =D
    Last edited by zeco; 09-19-2009 at 11:21 AM.

  9. #24
    Hell_Demon's Avatar
    Join Date
    Mar 2008
    Gender
    male
    Location
    I love causing havoc
    Posts
    3,976
    Reputation
    343
    Thanks
    4,320
    My Mood
    Cheeky
    Quote Originally Posted by zeco View Post
    And here in lies the problem. I thought by 7th year, you meant your grade or something :/

    And haha, you got a c++ book for your birthday? Lucky =D
    ah ok, sometimes i hate the way writing words cant explain it in the same way as saying it out loud ^^

Page 2 of 2 FirstFirst 12

Similar Threads

  1. IQOD #5
    By B1ackAnge1 in forum C++/C Programming
    Replies: 6
    Last Post: 09-21-2009, 03:33 PM
  2. IQOD #4
    By B1ackAnge1 in forum C++/C Programming
    Replies: 7
    Last Post: 09-20-2009, 01:37 PM
  3. IQOD #2
    By B1ackAnge1 in forum C++/C Programming
    Replies: 37
    Last Post: 09-19-2009, 04:40 PM
  4. Extra Credit IQOD #2A
    By B1ackAnge1 in forum C++/C Programming
    Replies: 18
    Last Post: 09-18-2009, 06:39 PM
  5. Interview Question of the Day (IQOD) #1
    By B1ackAnge1 in forum C++/C Programming
    Replies: 26
    Last Post: 09-18-2009, 04:24 PM

Tags for this Thread