Thread: Having problem with a program for Calculating Grades

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Third Eye Babkockdood's Avatar
    Join Date
    Apr 2010
    Posts
    352
    Quzah hit the nail right on the head. Also, return statements send output from a function to its caller.

    I recommend writing this program as one, big function, before breaking it down into multiple functions.
    Quote Originally Posted by The Jargon File
    Microsoft Windows - A thirty-two bit extension and graphical shell to a sixteen-bit patch to an eight-bit operating system originally coded for a four-bit microprocessor which was written by a two-bit company that can't stand one bit of competition.

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Babkockdood View Post
    I recommend writing this program as one, big function, before breaking it down into multiple functions.
    Granted there is not much code there so it could be just the mainline program.

    However; there is a lot of advantage in breaking larger jobs down to component blocks like the OP did and building explicit functions right from the beginning. If nothing else it compartmentalizes variable and effects on variables making the code easier to debug.

    When I write a program I first think about the best way to solve the problem... then I break it down to it's component parts... Get scores, calculate average, convert to letter grade etc. This breakdown is actually the basis for a list of functions that need to be written.

    Then when working on each of the parts --functions-- I only need to think about what I'm trying to accomplish at the moment, without worrying about the "big picture" at all. My variables are local and don't affect the mains, so if something messes up I don't have to troubleshoot my entire program, just the misbehaving bit.

    The "big blob" concept is fine for simple programs and examples, but when you start writing serious code it more often than not serves to undermine the problem solving effort.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 02-08-2009, 09:26 PM
  2. Using variables in system()
    By Afro in forum C Programming
    Replies: 8
    Last Post: 07-03-2007, 12:27 PM
  3. I have finished my program, one problem
    By sloopy in forum C Programming
    Replies: 4
    Last Post: 11-29-2005, 02:10 AM
  4. Program problem
    By Birdhaus in forum C++ Programming
    Replies: 6
    Last Post: 11-21-2005, 10:37 PM
  5. Problem with Program not Quitting
    By Unregistered in forum Windows Programming
    Replies: 20
    Last Post: 06-11-2002, 11:06 PM