Thread: A Few General C Questions

  1. #1
    Registered User
    Join Date
    Nov 2004
    Posts
    20

    A Few General C Questions

    I was given a few questions on a study guide for a computer science class. I am not sure of a few of them. If anyone could help, it would be greatly appreciated! Thanks for your help!!!
    -Jacob

    1. The two fundamental pointer operations are ______.
    a) initialization and declaration
    b) allocation and deallocation
    c) referencing and de-referencing
    d) increment and decrement

    2. The process by which global varialbes are allocated memory is called ____.
    a) automatic memory allocation
    b) dynamic memory allocation
    c) static memory allocation
    d) latent memory allocation

    3. Which of the following may NOT lead to the inefficient use of memory?
    a) failure to deallocate memory no longer in use
    b) having multiple pointers that reference the same memory location
    c) having an inaccessible chunk of memory
    d) static allocation of memory as in the case of an array

    4. Which of the following is true about a binary file?
    a) Its contents can be directly accessed using a text editor since it containts ASCII characters.
    b) Its contents can be randomly accessed.
    c) It is platform-independent since it can be transferred from one architecture to another without any problems.
    d) Processing binary files takes a considerably longer time than text files

    5. Which of the following is FALSE about a pointer-based implementation of a linked list?
    a) It uses self-referential structures.
    b) It involves dynamic memory allocation.
    c) Its length must be predefined.
    d) Any of its elements can be deleted while preserving all of its other elements.

  2. #2
    Registered User
    Join Date
    Mar 2004
    Posts
    494
    Read this http://www.cprogramming.com/tutorial.html all your questions are answered there.
    When no one helps you out. Call google();

  3. #3
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Why don't you post what you think the answers are, and we'll discuss them with you.
    So far, all you've done is posted your homework questions here, which no-one will do for you.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  4. #4
    Registered User
    Join Date
    Nov 2004
    Posts
    20
    Personally I think the answers are:
    1. c
    2. c
    3. b
    4. a
    5. d

    I have a good idea on some of them but just wanted some backing. I am not positive and would like to be. Again, all help is appreciated! Thanks!

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You're wrong on #5. One of the main benifits of a linked list is that you can walk through it, find any item, and remove it without too much trouble. (In the case of double linked lists, it's a snap.)

    Try again.

    Quzah.
    Hope is the first step on the road to disappointment.

  6. #6
    Slave MadCow257's Avatar
    Join Date
    Jan 2005
    Posts
    735
    Notice that on #5 b and c don't agree with each other, and this should be a flag that one of them is the right answer.

    Edit
    Personally, I thought #4 was wrong too but since Quzah didn't mention it I don't know =/
    Last edited by MadCow257; 02-16-2005 at 07:55 PM.

  7. #7
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    I agree with you on the first three questions ... but what do I know.

  8. #8
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Nmber 4 - google your way to find out what is meant by the term binary file.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  9. #9
    Registered User
    Join Date
    Nov 2004
    Posts
    20
    Ok, number 5 must be c then...right? It does allow for dynamic memory allocation and does not have to be predefined, at least that sounds right to me heh.

    How about 4? Is that one right? I would think a binary file would be impossible to open with a regular text editor. I would think it would appear as a bunch of junk. ??? Again, help is appreciated and thanks to all for the help so far! Keep the input coming! Thanks!!!

  10. #10
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Re-read the questions, I think you're mis-understanding them.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  11. #11
    Registered User
    Join Date
    Nov 2004
    Posts
    20
    Ok, 4 is b. =) I was definitely misreading the question. And 5 must be c because the whole point of using a linked list is dynamic memory allocation. Is my reasoning correct? Thanks guys!

  12. #12
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >>Is my reasoning correct?
    Yes.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  13. #13
    Registered User
    Join Date
    Nov 2004
    Posts
    20
    Thanks soo much guys! I appreciate it a lot! Thanks again!!

    ~~Jacob~~

  14. #14
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > 3. Which of the following may NOT lead to the inefficient use of memory?
    So you need advanced English just to unwind the double negatives in the question?

    > 5. Which of the following is FALSE about a pointer-based implementation of a linked list?
    That depends how you choose to implement the list.
    You can create a pointer based linked list inside an array if you want. The upper bound on the length of the list is fixed, and it doesn't involve any memory allocation.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. [Newbie] Quick general questions about C#
    By PaulBlay in forum C# Programming
    Replies: 1
    Last Post: 06-17-2009, 08:14 AM
  2. Password program / general programming questions
    By plr112387 in forum C++ Programming
    Replies: 13
    Last Post: 11-04-2007, 10:10 PM
  3. a few opengl(or general programming) questions
    By linuxdude in forum Game Programming
    Replies: 20
    Last Post: 06-14-2004, 07:47 AM
  4. FAQ: Examples of good questions (General)
    By Prelude in forum FAQ Board
    Replies: 1
    Last Post: 10-11-2002, 08:57 PM
  5. two general questions
    By Draco in forum C Programming
    Replies: 8
    Last Post: 05-17-2002, 10:46 PM