Thread: Logic

  1. #1
    Registered User
    Join Date
    Feb 2006


    In C++, logic plays an enourmous role. I feel I have no logic whatsoever. I know a good bit of code but I can not make a program whatsoever. Did anyone else have this problem? How could I overcome this problem of logic?

    Help will be greatly appreciated, thanks ahead.

  2. #2
    C++ Enthusiast jmd15's Avatar
    Join Date
    Mar 2005
    No, I never had that problem but the only way around it seems to be going through it. You NEED logic to code and to gain the skills neccessary to be logical you have to practice using logic. Through the use and practice of logical activities you can gain the neccessary skills. So my advice in a nutshell, practice.
    Trinity: "Neo... nobody has ever done this before."
    Neo: "That's why it's going to work."

  3. #3
    Registered User
    Join Date
    May 2006
    The Rules

    Program that for a 2 user game.
    Then expand to N users.

    This will make you more confident about your logical shortcomings.

    Also, Wikipedia has some interesting articles on logic, and the offshoots of logic.

  4. #4
    Registered User
    Join Date
    Feb 2006
    Oh haha, really good man, you really got me. How about posting something useful maybe?

  5. #5
    Registered User
    Join Date
    May 2006
    Its actually a really simple program for 2 users man.
    Just have each of those with an array that has the selection at 0, all the stuff that beats it as a positive, all the stuff that it beats as negative. then check.

  6. #6
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Waterloo, Texas
    the basic principles are found in the rules of boolean algebra and the operation of logic gates. learning how to solve/simplify logic equations using DeMorgan's laws and Kernaugh maps is a good idea, too.
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
        return std::pow
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;

  7. #7
    Hardware Engineer
    Join Date
    Sep 2001
    How about an example of what you are having trouble with? Programming logic isn't really that hard.

    But, if you are are new to programming (in the first few weeks of a programming class, for example) it can be tough, because you have to learn what programming is all about, how programs run/work, as well as learning C++ and how to use your compiler. I remember being really lost in my first programming class. It gets easier with your 3rd or 4th programming language. (Except for C++... Most of us will never learn C++ completely... There's a lot to it... You can't even find a book that covers the whole language!*)

    I know a good bit of code but I can not make a program whatsoever.
    You need to start-out by knowing what the program is supposed to do. Then, you can make a list, outline, or flowchart of how to get "from point A to point B."

    If you are given a homework assignment, most of that "outline" will be given (or hinted at) in the assignment. If not, there will be some good hints in the lecture/reading.

    It's important to know the kinds of things you can do in a program:

    Do stuff over & over.
    Make decisions based on conditions: if-statements & switch-case statements.
    Make calculations and comparisons.
    Input / output: Keyboard, display, disk, printer, etc.

    I usually make an outline, and I write it in the form of comments... starting each line with "//". Then, I start filling-in the actual code, and I'll edit the comments as I go-along so that the final comments to make them more "comment-like", and describe what the program is actually doing, rather than what it's supposed to do.

    * You can get a printed copy of the complete C++ Language Standard (the language “specification”).
    Last edited by DougDbug; 05-23-2006 at 05:57 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Digital Logic
    By strokebow in forum Tech Board
    Replies: 3
    Last Post: 12-09-2006, 01:05 PM
  2. Actors, cues, event based logic.
    By Shamino in forum Game Programming
    Replies: 2
    Last Post: 04-27-2006, 10:58 PM
  3. Logic problem
    By earth_angel in forum C Programming
    Replies: 6
    Last Post: 07-26-2005, 03:01 AM
  4. Circular Logic
    By DavidP in forum A Brief History of
    Replies: 1
    Last Post: 10-15-2001, 08:10 PM