Rockstars

Would you like to react to this message? Create an account in a few clicks or log in to continue.

Bored much? Check out Rockstar Summer Event!

Navigation

Clan Playlist



2 posters

    Understanding Basic C++ Logic

    Heero
    Heero


    Posts : 155
    Reputation : 11
    Join date : 2008-11-24

    Understanding Basic C++ Logic Empty Understanding Basic C++ Logic

    Post by Heero Tue 27 Oct 2009, 2:38 pm

    Kay so I'm doing this because I really have nothing better to do not being able to play gunz and no one being home at the moment, so let's get started!

    C++ is a programming language that almost all modern day operating systems are built off of. It is a series of commands that tells the hardware to build a virtual environment and make it do something. All code has a job, and until it's job is finished it will continue to run until it reaches it's end line conditions. An end line condition is a conditional statement that says, once ________ has done _________ do ________ . So let's say I make a basic program that tells the computer to:

    Print a line of text; wait for user input; exit;

    Here is a basic example of what that would look like in c++
    =====================================

    #include
    using namespace std;

    int main()
    {
    std::cout <<"This text will be printed\n";
    system("pause")
    return 0;
    }
    =====================================
    Understanding Basic C++ Logic Thistextwillbeprinted
    -
    Understanding Basic C++ Logic Compile
    -
    Understanding Basic C++ Logic Savecompile
    -
    Understanding Basic C++ Logic Compileprogress
    -
    Understanding Basic C++ Logic Run
    =====================================
    [output]
    This text will be printed
    Press any key to continue...
    -
    Understanding Basic C++ Logic Runoutput
    =====================================
    Now if you don't get any of that code above the output, I'll explain

    In the first line (#include ) this tells the compiler that you are using to compile your code to use this to interpret it. There are many things you could #include, but almost all programs start with that particular line.

    The second line is a native c++ command telling the compiler to use the std function which is a standard for all cout/cin lines. Basically what it does is allows me to type cout or cin instead of std::cout or std::cin and save me time if I'm going to be doing that a lot.

    The third line (int main()) is our main function, and will be the block of code that is run first. In a lot of cases it'll be the only code that will be run, unless you're using multiple files that will be run in conditional statements.

    The fourth line which is an open curly bracket tells the compiler, this is where the code starts, and this is where you need to execute things. The closed curly brackets at the bottom tells the compiler that it is the end of the code and that it can stop now, but on to line 5.

    std::cout <<"This text will be printed\n"; , This line has a few c++ terms which may be confusing at first but I'll explain Smile . First, cout: cout means Computer Out, it tells the computer to give some output of what it's being told to output. So if I told it cout << 5 * 2; , it would say 10. Anytime you want the computer to print text, you put it into quotation marks "like so". The \n before the end quotation marks means, this is the end of the line, anything after this should be printed on a new line. Finally the semi colon ; . Every line in c++ ends with a semicolon, this tells the compiler to move on to the next line and it makes it easier for the programmer to read the code.

    The sixth line is a simple windows CMD command that will print the line "Press any key to continue..." This is useful if you want to see the output of your program because remember, once the program has done everything it is suppose to, it'll close. So the program won't close till the user presses a key Smile . I'll explain this line though. If you were to make a .bat file, and type "pause" without quotation marks, and run it, it would simply say "press any key to continue...". Well c++ doesn't have a function to print that line, so what we do is we tell it to talk to system which is a phrase that tells the compiler to exec a windows .bat command. What this does is allows the programmer to do very simple tasks that would normally be difficult. You simply type, system() and inside the parenthesis you type the parameters, which are commands.

    Lastly, as I explained up above, you end your main function with a closing curly bracket }.

    Now I know this seems like a lot of work, but it really isn't, it's just hard for some people to understand without being completely walked through it. I myself didn't have much trouble learning basic programming since I'm very interested in logic and how things work Smile . Really all programming is, is math with the addition of words. If you know algebra and calculus you'll probably have no problem learning any logical programming language ^_^.

    If you're interested in this, I can point you in the direction of better tutorials and a compiler so you can learn to program too Smile! I hope you have enjoyed this HeeroGeekTut.

    -Heero


    Last edited by Heero on Tue 27 Oct 2009, 6:19 pm; edited 1 time in total
    Xinuix
    Xinuix


    Posts : 410
    Reputation : 3
    Join date : 2008-11-14

    Understanding Basic C++ Logic Empty Re: Understanding Basic C++ Logic

    Post by Xinuix Tue 27 Oct 2009, 3:35 pm

    Wootfor C++! XD I'm working with the graphics component of it right now, which deals with OpenGL. Heero, are you in a technical school or anything? O_O Because I think you'd do pretty damn well.
    Heero
    Heero


    Posts : 155
    Reputation : 11
    Join date : 2008-11-24

    Understanding Basic C++ Logic Empty Re: Understanding Basic C++ Logic

    Post by Heero Tue 27 Oct 2009, 6:09 pm

    Xinuix wrote:Wootfor C++! XD I'm working with the graphics component of it right now, which deals with OpenGL. Heero, are you in a technical school or anything? O_O Because I think you'd do pretty damn well.

    Lulz I'm a high school drop out, didn't even finish 10th grade, gonna get my GED pretty soon, only 17, turn 18 in January, and I'm planning on going to some tech school or community college and transfer to something bigger. I dunno if I want to get a degree in comp sci though because I hear being a programmer nowadays is kinda fail unless you do something ground breaking which is sorta hard to do :p. Aside from c++ I'm also learning java, python, and html/php at the same time, oh and Japanese. Eventually I'll learn js and stuff but I thought I'd tackle the ez stuff first.
    Xinuix
    Xinuix


    Posts : 410
    Reputation : 3
    Join date : 2008-11-14

    Understanding Basic C++ Logic Empty Re: Understanding Basic C++ Logic

    Post by Xinuix Thu 29 Oct 2009, 1:44 pm

    I've also heard that learning some database languages, such as C# may be a more practical way of gaining knowledge because a lot of big-end systems use databases for inventory and such. And getting a comp sci degree isn't completely fail, as I believe the market will be looking for more software programmers. There's more jobs in comp sci than in most other areas right now, because computers are everywhere o_O, and although hardware has a physical limit, there's always people looking for ways to improve software to make it more efficient.

    By js I'm guessing you're talking about javascript? O_o. I'm sure if you can program in PHP or anything net-based, javascript wouldn't be too hard. That, and the fact that it looks a lot like Java, fancy that. XD
    Heero
    Heero


    Posts : 155
    Reputation : 11
    Join date : 2008-11-24

    Understanding Basic C++ Logic Empty Re: Understanding Basic C++ Logic

    Post by Heero Thu 29 Oct 2009, 11:22 pm

    Xinuix wrote:I've also heard that learning some database languages, such as C# may be a more practical way of gaining knowledge because a lot of big-end systems use databases for inventory and such. And getting a comp sci degree isn't completely fail, as I believe the market will be looking for more software programmers. There's more jobs in comp sci than in most other areas right now, because computers are everywhere o_O, and although hardware has a physical limit, there's always people looking for ways to improve software to make it more efficient.

    By js I'm guessing you're talking about javascript? O_o. I'm sure if you can program in PHP or anything net-based, javascript wouldn't be too hard. That, and the fact that it looks a lot like Java, fancy that. XD

    Yeah but the root of the the fail is the fact that there are so many unemployed people with a comp sci degree and it's because the need for a programmer can be filled with pretty average people now. All you need is a person who is resourceful and whom can concentrate for extended periods of time. I'm pretty sure if Darylin wanted to she could go on Google right now and learn any programming language. It's not terribly hard you just need a bit of patience. Quite obviously having a degree automatically puts you at a higher status for documented occupational standards, but the fact is most programmers who are GOOD at what they do, don't have degrees, and they work for themselves or they don't work at all and are dead broke. The life of a programmer is the life of an artist really, you do it because it's a passion and you enjoy doing it Very Happy. I'm also a firm believer in "Work is boring" and I don't want what I enjoy doing to become "Work". I dunno, it's a mindset kind of thing, some people get it and some poeple don't.
    Xinuix
    Xinuix


    Posts : 410
    Reputation : 3
    Join date : 2008-11-14

    Understanding Basic C++ Logic Empty Re: Understanding Basic C++ Logic

    Post by Xinuix Fri 30 Oct 2009, 2:02 am

    I understand what you mean Heero, and I completely agree. Even in my faculty, I really do not study to become a programmer. I do it to have something under my belt, filling up the occupational standards, if you will. Wink In all honesty, to me most programming assignments suck ballsack XD. I just do them because I have to. The real essence is the application outside of school, and you are right in that most people could probably fill the roll of a programmer so long as they can break down the abstract ideas and can focus on it. The thing is, not many people do. Computers in general, to most it's a source of media, a black box like a car, where dissecting it is "somebody else's job". That's the exact reason why those spots are reserved for enthusiasts that care enough to bring their knowledge to the table and use it as inspiration for them to work. Not many people like the idea of programming, just like a lot of people don't like the idea of lab-work in a white coat. But hey, if you do, and you want money for it, that's not a bad trade-off XD.

    Besides, most of the time now, companies have their code developed in other countries. North America is more for the business analyst who can speak the language, but interacts with people more than computers. At least that is what I have been able to conjure up from my work experience thus far. I guess what I am trying to nail down essentially is that computer science and programming isn't just what we believe it to be. There's a whole network of other things that allow for any programmer to even begin considering writing that first line of code. Smile
    Heero
    Heero


    Posts : 155
    Reputation : 11
    Join date : 2008-11-24

    Understanding Basic C++ Logic Empty Re: Understanding Basic C++ Logic

    Post by Heero Tue 03 Nov 2009, 8:59 pm

    Xinuix wrote:I understand what you mean Heero, and I completely agree. Even in my faculty, I really do not study to become a programmer. I do it to have something under my belt, filling up the occupational standards, if you will. Wink In all honesty, to me most programming assignments suck ballsack XD. I just do them because I have to. The real essence is the application outside of school, and you are right in that most people could probably fill the roll of a programmer so long as they can break down the abstract ideas and can focus on it. The thing is, not many people do. Computers in general, to most it's a source of media, a black box like a car, where dissecting it is "somebody else's job". That's the exact reason why those spots are reserved for enthusiasts that care enough to bring their knowledge to the table and use it as inspiration for them to work. Not many people like the idea of programming, just like a lot of people don't like the idea of lab-work in a white coat. But hey, if you do, and you want money for it, that's not a bad trade-off XD.

    Besides, most of the time now, companies have their code developed in other countries. North America is more for the business analyst who can speak the language, but interacts with people more than computers. At least that is what I have been able to conjure up from my work experience thus far. I guess what I am trying to nail down essentially is that computer science and programming isn't just what we believe it to be. There's a whole network of other things that allow for any programmer to even begin considering writing that first line of code. Smile

    Agreed. My last comment on your point-of-view would have to be that I like to be able to do things without dead-lines Very Happy . I'm not really a procrastinator with programming as much as I like to process things slowly and make sure that I fully learn them. Pressure of work and school would destroy my morale and make me a useless employee. I honestly have no real goals in life dunno what the hell I'm going to do occupationally and financially but meh, I'm only 17 I'll get a job here soon and figure that stuff out while I do the work that I shouldn't be doing. xD

    Sponsored content


    Understanding Basic C++ Logic Empty Re: Understanding Basic C++ Logic

    Post by Sponsored content


      Current date/time is Fri 26 Apr 2024, 4:38 am