-->

Getting to Know C++ Programming Language


C++ is an amazing programming to learn. If your dream is to become a games designer or work at the cutting edge of science or engineering technology, then being able to code in C++ is a must. Remember, you’re never too old to learn how to code.

#INCLUDE <C++ IS ACE!>


Learning the basics of programming, through Python for example, enables you to understand the structure of a program. The commands may be different, but you can start to see how the code works.

C++


C++ was invented by Danish student Bjarne Stroustrup in 1979, as a part of his PhD thesis. Initially C++ was called C with Classes, which added features to the already popular C programming language, while making it a more user-friendly environment. Bjarne Stroustrup, inventor of C++.






#INCLUDE

The structure of a C++ program is slightly different to that of Python and radically different to BASIC. Every C++ code begins with a directive, #include <>. The directive instructs the pre-processor to include a section of the standard C++ code. For example: #include <iostream> includes the iostream header to support input/output operations.



INT MAIN()


int main() initiates the declaration of a function, which is a group of code statements under the name ‘main’. All C++ code begins at the main function, regardless of where it actually lies within the code.





BRACES


The open brace is something that you may not have come across before, especially if you’re used to Python. The open brace indicates the beginning of the main function and contains all the code that belongs to that function.




COMMENTS


Lines that begin with a double slash are comments. This means they won’t be executed in the code and are ignored by the compiler. Why are they there? Comments are designed to help you, or another programmer looking at your code, explain what’s going on. There are two types of comment: /* covers multiple line comments, // a single line.




The two chevrons used here are insertion operators. This means that whatever follows the chevrons is to be inserted into the std::cout statement. In this case the words are ‘Hello World’, which are to be displayed on the screen when you compile and execute the code.



STD


While std stands for something quite different, in C++ it means Standard. It’s a part of the Standard Namespace in C++, which covers a number of different statements and commands. You can leave the std part out of a code, but it must be declared at the start with:
using namespace std.




COUT


In this example we’re using cout, which is a part of the Standard Namespace, hence why it’s there, as you’re asking C++ to use it from that particular namespace. Cout means Character OUTput, which displays, or prints, something to the screen. If we leave std:: out we have to declare it at the start of the code, as mentioned previously.



OUTPUTS


Leading on, the (“Hello World!”) part is what we want to appear on the screen when the code is executed. You can enter whatever you like, as long as it’s inside the quotation marks. The brackets aren’t needed but some compilers insist on them. The \n part indicates a new line is to be inserted.



; AND }


Finally you can see that lines within a function code block (except comments) end with a semicolon. This marks the end of the statement and all statements in C++ must have one at the end or the compiler will fail to build the code. The very last line has the closing brace to indicate the end of the main function.




0 Response to "Getting to Know C++ Programming Language"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel