Thread: Flow chart or state diagram

  1. #1
    Registered User
    Join Date
    Feb 2012
    Posts
    347

    Flow chart or state diagram

    Sorry it is not a pure c question but please explain me. I am confused with state diagram and flow chart. Should i do C program based on flow chart or state diagram. I am finding state diagram easy to implement. Please help.

  2. #2
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    Use whatever seems appropriate to help you plan your logic. For instance, I occasionally use flow charts when I have to institute a complex set of dependent conditions, since it helps me visualize all the necessary logical branches. More often, pseudocode is sufficient to determine the logic, with the added benefit of easy pseudocode-to-code translation.

  3. #3
    Registered User
    Join Date
    Feb 2012
    Posts
    347
    Thank you for the reply. Does pseudo code development involves some tools and will they automatically generate C code. I am finding it very difficult to maintain C code and also development is taking lot of time. In some or the condition i am failing to update a flag and etc. How to reduce these kind of mistakes? Any suggestions.

  4. #4
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    I just use a simple text editor for most of my pseudocode development. It is your responsibility to convert it to code.

    For more sophisticated programs, I spend much more time on planning and pseudocode than actual coding. You can read through the pseudocode to ensure the logic makes sense and is correct. It also helps identify values you will need, repeated actions that can be partitioned into separate functions, etc. It can also serve as informal documentation on the logic (as long as you keep it updated if things change during coding).

    The more detailed your pseudocode, the easier it is to translate into actual code. If updating a flag is important to a given algorithm, the pseudocode should show this - omitting it is a logical mistake that should found during a review (well before any actual coding has taken place).

    If you're a beginner, and have sufficiently detailed pseudocode, a good technique is to copy/paste the pseudocode into your source file, comment each line, and below each line write the corresponding code. When you're done, deleted the commented lines (as such verbose comments in the final code are not needed). Since you already know the logic is sound (since it should have been verified earlier), you have a much better chance of writing correct code the first time around.

    Quote Originally Posted by Satya View Post
    ... and also development is taking lot of time.
    Proper design does take a lot of time, but helps reduce time coding, since you (1) don't have to figure things out as you go, and (2) don't have to do major code re-writes because certain things had not been taken into account. The more time you spend planning, the better your logic will be and the easier it will be to write efficient code.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C Code for a flow diagram
    By unity006 in forum C Programming
    Replies: 4
    Last Post: 11-08-2015, 04:24 PM
  2. Flow chart
    By SimplyNice in forum C Programming
    Replies: 5
    Last Post: 03-20-2011, 06:22 AM
  3. flow chart
    By rafay07 in forum C++ Programming
    Replies: 6
    Last Post: 04-13-2010, 12:42 PM
  4. Flow Chart
    By strokebow in forum C++ Programming
    Replies: 2
    Last Post: 11-13-2008, 08:57 AM
  5. flow chart
    By SPOOK in forum C Programming
    Replies: 0
    Last Post: 10-08-2001, 02:45 PM

Tags for this Thread