Thread: two small queries

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    254

    two small queries

    The quoted text is from a book.

    The most important reason to use functions is to aid in the conceptual organization of a program. Dividing a program into functions is, as we discussed in Chapter 1, “The Big Picture,” one of the major principles of structured programming. (However, object-oriented programming provides additional, more powerful ways to organize programs.)

    Another reason to use functions (and the reason they were invented, long ago) is to reduce program size. Any sequence of instructions that appears in a program more than once is a candidate for being made into a function. The function’s code is stored in only one place in memory, even though the function is executed many times in the course of the program. Figure 5.1 shows how a function is invoked from different sections of a program.
    I don't think the most important reason to use functions is to aid in the conceptual organization of a program rather the most important reason is to reduce the size of the program and save memory. What do you say? Please let me know.

    24. A default argument has a value that
    a. may be supplied by the calling program.
    b. may be supplied by the function.
    c. must have a constant value.
    d. must have a variable value.
    According to the book the answers are "a" and "b". I don't understand how "a" could be the answer. Please help me. Thanks.
    I'm an outright beginner. Using Win XP Pro and Code::Blocks. Be nice to me, please.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by jackson6612
    I don't think the most important reason to use functions is to aid in the conceptual organization of a program rather the most important reason is to reduce the size of the program and save memory. What do you say?
    Well...
    Quote Originally Posted by Abelson and Sussman
    Programs must be written for people to read, and only incidentally for machines to execute.
    Quote Originally Posted by jackson6612
    According to the book the answers are "a" and "b". I don't understand how "a" could be the answer.
    When the caller chooses not to use the default value.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    Quote Originally Posted by jackson6612 View Post
    I don't think the most important reason to use functions is to aid in the conceptual organization of a program rather the most important reason is to reduce the size of the program and save memory. What do you say? Please let me know.
    I agree with your book and strongly disagree with you in this case.

    For anything except a small program, human effort is the dominant practical driver (exceeding 80% in a lot of studies, and exceeding 90% in quite a few studies) of cost and time to get a program working correctly and then maintaining it. Anything that reduces human time and effort is therefore critical to reducing development cost, effort, and ensuring program correctness. Functions make a program easier to think about, so are an important tool for reducing development cost (albeit not the only one).

    Note in the above, my working definition of a "small program" probably covers programs that you might consider to be on the large side. I personally define a small program as one for which the first five years of its development life cycle (design, development, initial maintenance) takes less than ten man years of effort.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. special queries for databases
    By Leite33 in forum Windows Programming
    Replies: 2
    Last Post: 12-27-2006, 05:23 AM
  2. Running SQL queries server side with C++?
    By taelmx in forum Networking/Device Communication
    Replies: 2
    Last Post: 10-10-2006, 07:59 PM
  3. DLL Making and Symbols - 2 Queries
    By Tronic in forum C++ Programming
    Replies: 9
    Last Post: 12-31-2004, 01:11 AM
  4. text file queries
    By ozzy34 in forum C++ Programming
    Replies: 2
    Last Post: 09-30-2004, 10:42 AM
  5. Hash File Queries
    By 1999grandamse in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2002, 02:18 PM