Thread: newbie on programming

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    3

    newbie on programming

    ok i just got a stupid question about programming this is my first time ever seeing codes and reading about them and some things i cant under stand like on the second tut. in Learning to Program in C++ Lesson 2: If statements i dont understand what its trying to say if some 1 can put it in lamans terms if pospible ive been trying to learn this for like 4 months and cant get passed the second lesson lol

  2. #2
    Registered User
    Join Date
    Jun 2004
    Posts
    124
    You're going to need to post a more specific question, give a code example of a particular if statement you are having trouble understanding.

    In general they work like this:

    Code:
    if (condition)
    //Do something
    else
    //Do something else
    Of course there is endless complexity inherent in a conditional statement, which is why you need to provide a more specific question.

  3. #3
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by FRO212 View Post
    ok i just got a stupid question about programming this is my first time ever seeing codes and reading about them and some things i cant under stand like on the second tut. in Learning to Program in C++ Lesson 2: If statements i dont understand what its trying to say if some 1 can put it in lamans terms if pospible ive been trying to learn this for like 4 months and cant get passed the second lesson lol
    Sorry. Not really sure what "layman's term" I would use to describe the meaning of the word "if."

  4. #4
    Registered User
    Join Date
    Apr 2007
    Posts
    3
    well the whole < > less and gratter thing
    > greater than 5 > 4 is TRUE
    < less than 4 < 5 is TRUE
    >= greater than or equal 4 >= 4 is TRUE
    <= less than or equal 3 <= 4 is TRUE
    == equal to 5 == 5 is TRUE
    != not equal to 5 != 4 is TRUE

    i under stand want to type how 5 is grater the n 4 and all that but just not how it would fit in a program and how it can be used and also it stated something about user names and i was just courious about how i would go about putting a user name and pass in to a program just for a refreance to when i do start making a program and get decent with it

  5. #5
    Registered User
    Join Date
    Apr 2007
    Posts
    27

    Code is frustrating...

    ...and you'll just have to get used to it. However if you've been on that for four months, you haven't been trying very hard lol. It can be VERY usefull in programs, I still use it and I'm in the early stages of creating a full-fledged game. It can error detect such as:

    Code:
    if  (value == BADVALUE)
    {
    //tell user that the bad value is coming up
    }
    else
    {
    //run system as normal
    }
    I had to do a tax program before once for a class, I don't remember, but i'm pretty sure no switches were allowed. Anyway, the user input all kinds of variables for their money earned, interest earned, taxes paid, tax deductables... and so the if statements made a bulk of the actual code (that wasn't reading in data) because it had to figure out what tax bracket they were in, and what exceptions they had.
    If statements for a regular cmd window program (that black window with grey courier new font) are also great for doing simple reading in of user data for answers to questions. I had to do a price handling program imitating a local ferrie's rates. Essentially how many passengers, if they had a car or a bike, what class they were riding in, (class being just first or third, it wasa LONG time ago,) and a few other questions, most being yes/no questions. So if user input == yes, or 'y' or 'Y' or '1' or whatever, you can check for that and only execute something if it "fits the bill". There are near endless uses for if. If you look into my question in "problems with GetAsyncKeystate()" you'll see that my whole problem (I thought) was dealing with an if statement, to switch between two different (and popular) RTS camera modes.

    Code:
    if (user is holding alt)
    {
    //aim camera
    }
    else
    {
    //move camera
    }
    Very useful. Try not to judge the usefullness of seemingly useless functions until you've used them before. Operator overloading to me right now, seems inherantly useless to my tastes, as I could just call the function that does what it does, but for the sake of saving coding lines, and making it easier to read, it might be usefull once I understand it's complexities and have put it to use in a few practice programs. (Probably mainly saves space for the fact that no function call is needed, and you could possibly use them to take someone elses code and completely change the use for it by adding your header file to it). Alas.. i've digressed. Just learn, THEN judge. Not the shoot-and-ask-questions-later method; much less affective in coding.

  6. #6
    Registered User
    Join Date
    Apr 2007
    Posts
    3
    well on that i just never figured it out and i just started reading it againand just got stuck but i think i understand it ill probly be asking more questions on c++ but ive been verry instered in it for like 5 yrs now just never took the time to read about it and now im finaly doing so and i wish some 1 would help me under stand more but ill get threw it on my owna and ask questions i dont know and try to make a few programs

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. newbie: array question :(
    By cstudent in forum C Programming
    Replies: 2
    Last Post: 04-09-2008, 06:46 AM
  2. getting to grips with allegro and ms vc++ (newbie)
    By jimjamjahaa in forum C++ Programming
    Replies: 4
    Last Post: 11-18-2005, 07:49 PM
  3. Newbie in problem with looping
    By nrain in forum C Programming
    Replies: 6
    Last Post: 11-05-2005, 12:53 PM
  4. C++ newbie / linux not so newbie question
    By goldmonkey in forum C++ Programming
    Replies: 7
    Last Post: 12-13-2003, 12:27 PM
  5. Newbie Game Develpoers Unite!
    By Telenosis in forum Game Programming
    Replies: 10
    Last Post: 06-22-2002, 02:02 PM