View on GitHub

LetsLearnProgramming

How we can program FRC robots in C++

Let’s Say Hello!

Objectives: Learn the basics of code and write a hello world program.

Starting Point: This code

Process:

  1. Open up the starting point. And click the text that says “fork.”
    1. Lets quickly look at the template of this program. At the top we have a lot of #include lines. This is the header section. This is where we tell the computer what type of words we’ll be using. The computer understands many words on its own, by including these resources, we’re giving the computer additionally dictionaries so that it can look something up if it doesn’t know the words.
    2. Next we have:

      int main()

      This is the starting square for the program. Just like monopoly always starts at “GO”, the program always starts at main. After main we see curly open and close brackets “{ }” on different lines. Between these brackets is the main body of the code. This is because they are in the brackets that come after the name “main”.

  2. Inside the main body, we’re going to write the following line:

    printf();

    Inside the printf parenthesis, write something that you want printed to the screen. Traditionally, the standard is to write “Hello World”. Make sure that whatever you pick is surrounded by “double quotes.“ I decided to write “I am a banana” so my code would look like this:

    printf(“I am a banana”);

  3. Now that we wrote our first code, lets see if it works! On the bottom right, there is a green button labeled “run,” press it!

    If everything went well, the box beneath the code will display the text you wrote. If it didn’t go well, you’ll see some error messages under the label “compilation info.” Double check that you included a semicolon “;” at the end of your statement, that you spelled and capitalized printf correctly, that you are using double quotes inside the parenthesis, and that you have both parenthesis. If you found any errors, click the “edit” text in the top right left hand corner and fix them. The green run button might say “ideone it!” now, but it’s the same thing. Click the button and see if your fixes worked! Ask for help if you can’t figure out the errors.

    Tada! You did it! Feel free to change what your code prints out to play with it.


Next: Let’s Learn Variables! ->

Back to Main