Beginner’s Guide to C++ Overview

In our daily life we talk about technology news and know that programming is one of the interesting and healthy growing fields in the industry. Information technology is being used in every field of life in order to control users, data and other management etc. Programming is all about creativity and many people want to learn its basics. So those who have never programmed before and they are interested in C++ programming; they can take this article as a guide to start with. You just need some motivation and patience. Initially, it may look little difficult but once you get the knowledge, you can be a good programmer.

Instructions

  • 1

    Getting started

    The best way to learn programming is to write program first and then make changes accordingly as required.

    Code:

    // my first program in C++

    #include

    using namespace std;

    int main ()

    {

    cout << "Hello World!";

    return 0;

    }

    Output:



    Hello World!

    This is a basic and easy code. Once this program is compiled and executed then it will show its output that will print “Hello World!”

    Now we will learn about it line by line.

  • 2

    First program in c++

    Let’s check our first line of code that is

    // my first program in C++

    Here by // means that this line is a comment. In C++ when we have something to remember or to explain code we need a comment that helps to understand code in less time. In c++ you can find comments in two ways, one is the above mentioned and the other is /* comment *\ .

  • 3

    #include

    Any line starting with the sign “#” means that it is derivative for the preprocessor. So these are not ordinary lines in code with this expression but these are compiler preprocessor’s indications.

    Here the directive is #include

    alerts the preprocessor to include the iostream standard file. And that specific file is (iostream). This file includes basic standards of I/O declarations in c++ library. By including them in code means that its functionality will be used in the program.

  • 4

    using namespace std;

    By using this line of code means that each element from the standard library of c++ is declared in namespace with std. In order to access its functionality we assert with this expression that we will be using these entities. This line is very recurrent in C++ programs that use the standard library.

  • 5

    int main ()

    This is beginning of the main function . Main function is a position from where all c++ programs run their parallel execution within the source code. There can also be many other functions used in the program as they don’t have any effect on main function. Instructions enclosed within this function's definition will always executed first. In short, it is must for c++ program to have main function in it.

  • 6

    Opening Brackets:

    {

    This is a curly bracket that is used in start and end of main function in order to differentiate chunks of code when we have maximum lines of code.

  • 7

    cout << "Hello World!";

    return 0;

    this is c++ statement that is responsible to output the string shown in “”.

    Cout<<: “cout” is a function that ask compiler to display the output. Also cin.get() is to hold the program until any key is being pressed. Whereas “return 0”; is to exit code.

  • 8

    Closing bracket:

    }

    Function ends when the bracket is closed.

  • 9

    So this was very simple and basic program to simply understand few terms and function along with c++ programming structure. This program will print

    Hello World on your screen. You can replace it with anything and can play with it by using your own logic and creativity.

Leave a Reply

Your email address will not be published. Required fields are marked *


3 − three =