I have a question about some homework?

This is a discussion on I have a question about some homework? within the C Programming forums, part of the General Programming Boards category; Hello, I have three questions i wish everyone to please check to see if i am correct. If not could ...

  1. #1
    TransparentMember correlcj's Avatar
    Join Date
    Jun 2002
    Posts
    378

    I have a question about some homework?

    Hello,
    I have three questions i wish everyone to please check to see if i am correct. If not could you display the correct answers and briefly why you cjose that answer, please?

    Q1: A pointer variable contains?
    a. an int
    b. address of another variable
    c. any data type
    d. char string

    I chose B

    Q2: The term "defreferencing" means?
    a. taking the address of another variable
    b. delete a variable
    c. retrieving the value of a variable given its address
    d. making an assignment to a pointer

    I chose C

    Q3: A void* is?
    a. pointer whose value is 0
    b. an uninitialized pointer
    c. a way of representing an error condition
    d. an untyped pointer

    I chose A

    Thanks!
    "Be formless, shapeless, like water... You put water into a cup, it becomes the cup, you put water into a bottle, it becomes the bottle, you put it in a teapot, it becomes the teapot... Now water can flow, or it can crash, be water my friend."
    -Bruce Lee

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Q1: A pointer variable contains?
    Well, if you have to choose from the list of given answers, then you've got it right. But, consider a NULL pointer. That does not have the address of another variable in it.

    Q2: The term "defreferencing" means?
    You are correct.

    Q3: A void* is?
    You are incorrect. Please try again!
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >Q1: A pointer variable contains?
    a. an int
    b. address of another variable
    c. any data type
    d. char string

    Answer: None of the above. A pointer holds an address in memory, but this may or may not be a variable. For example:

    char *p = "A string literal";

    This pointer points to a string, but that string is not a variable and may not be modified safely. It is also possible to assign an arbitrary address directly, but this is hardly useful unless you are doing down and dirty hardware work where the address is known and always the same.

    But the answer the question expects is B.

    Q2: The term "defreferencing" means?
    a. taking the address of another variable
    b. delete a variable
    c. retrieving the value of a variable given its address
    d. making an assignment to a pointer

    Answer: Once again this could be "more right" as dereferencing is a synonym for indirection which accesses the object that a pointer points to and returns that object or function. Indirection can be performed on more than just variables, the question implies otherwise. The answer that they expect is C.

    Q3: A void* is?
    a. pointer whose value is 0
    b. an uninitialized pointer
    c. a way of representing an error condition
    d. an untyped pointer

    Answer: A void pointer is C's generic pointer type. It is incomplete and cannot be dereferenced, but it can be converted and/or coerced into another pointer type which is more usable. I would imagine that this question expects D as the correct answer.

    -Prelude
    My best code is written with the delete key.

  4. #4
    TransparentMember correlcj's Avatar
    Join Date
    Jun 2002
    Posts
    378

    I have my doubts?

    For Q1 hammer i was somewhat leaning towards answer C but picked B. Simply because it can contain an address and a int. unless i am reading the question wrong. But i am glad to confirm my answer was correct.
    Q3: i chose A because i guessed. I am learning C on my own and from the help of people like yourselves. In the book it says"thinik of it as a void* as a generic pointer type. I understand also that it says one pointer can be assigned to anither if they both have the same types. What does this short paragrapgh tell me. Well not the answer to Q3 obviously and if I guessed hard enough i would say the answer would have been D?
    "Be formless, shapeless, like water... You put water into a cup, it becomes the cup, you put water into a bottle, it becomes the bottle, you put it in a teapot, it becomes the teapot... Now water can flow, or it can crash, be water my friend."
    -Bruce Lee

  5. #5
    TransparentMember correlcj's Avatar
    Join Date
    Jun 2002
    Posts
    378

    Thanks!

    Of course, prelude!
    Thanks!
    That makes alot of sense now.
    I appreciate it.
    cj
    "Be formless, shapeless, like water... You put water into a cup, it becomes the cup, you put water into a bottle, it becomes the bottle, you put it in a teapot, it becomes the teapot... Now water can flow, or it can crash, be water my friend."
    -Bruce Lee

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question About My Homework Pls Help Me İmmediately
    By jennyyyy in forum C Programming
    Replies: 27
    Last Post: 03-13-2008, 11:40 AM
  2. quick question
    By surfingbum18 in forum C Programming
    Replies: 5
    Last Post: 12-04-2007, 05:16 AM
  3. Design layer question
    By mdoland in forum C# Programming
    Replies: 0
    Last Post: 10-19-2007, 04:22 AM
  4. opengl DC question
    By SAMSAM in forum Game Programming
    Replies: 6
    Last Post: 02-26-2003, 08:22 PM
  5. Very simple question, problem in my Code.
    By Vber in forum C Programming
    Replies: 7
    Last Post: 11-16-2002, 02:57 PM

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