Learning C++ - Part 2 - Writing your first C++ program

in programming •  7 years ago 

Untitled-1.jpg
Hello everybody, it is "Not Funny" with another post about the C++ Language.
I really recommend you to visit my previous post it will show you how to download Code Blocks and as a reminder download the IDE from here and choose this setup.

Capture.PNG

Any setup but that won't work correctly.

Writing your first C++ program!

Capture.PNG First of all, click the add button so our file can be visible, same for "source" and you gonna find a text file called 'main.cpp' (by the way cpp = c++) double click on it and you gonna something like this.
Capture.PNG

And because you are new to the C++ language just modify it to this so it can be much simpler to deal with.

Capture1.PNG

Understanding the code

  1. First of all let's try to understand the first line.
    "iostream" is header that defines the standard input/output stream objects, think of it like a box that contains things called methods (you might not understand what is a method but we will talk about it more in future posts.

Box.jpg

  1. Capture.PNG is a function wich will cover in future posts but for now all you need to know about it is that it is from where the execution of the code starts, if main isn't present your code won't run.

  2. Capture.PNG std::cout is a method that exists in the header "iostream", it basically allows us to print text in the console, for example the output of our code will be :

    Capture.PNG

    std::endl means that it is the end of the line so any syntax wrote after it will be in the next line.

  3. Capture.PNG we will talk about "return" more in the futur, the code, by convention, expects your main() to return 0 on success, and any other value on failure.

This is all for today's post, upvote if it helped you, and ask questions if you didnt understand something in the comment section.
See you later!

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Congratulations @pentest1002! You have received a personal award!

1 Year on Steemit
Click on the badge to view your Board of Honor.

Do not miss the last post from @steemitboard:

Trick or Treat - Publish your scariest halloween story and win a new badge
SteemitBoard notifications improved

Support SteemitBoard's project! Vote for its witness and get one more award!

Congratulations @pentest1002! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 2 years!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Vote for @Steemitboard as a witness to get one more award and increased upvotes!