Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Learn Basic Structure of C++ Programming for Beginner

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 566
    Comment on it

    Prior to creating a C++ program, one needs to start the C++ IDE. The instructions for starting C++ all depend on the system one is using. This unit assumes that the individual is using the Bloodshed compiler. Incase, one uses a different version of C++, he then needs to review the compiler documentation regarding the important for starting his particular version.

     

    Basic structure of a C++ program

    The basic structure of a simple C++ program comprises of the following:

     

    Listed below is the documentation about this software which encompasses the directive(s) main function

     

    Every software-typically should have internal documentation which identifies the important information regarding the program, like the name of the software, author, date, filename where the software has been saved, limitations of the program, etc. Documentation should also be performed throughout the source code for indicating the "what" of the software statements. Your code must be clear and consistent. Avoid "spaghetti code." This documentation can help the programmer save quite a lot of time in the future when the user references, debugs, or modifies the program.

     

    The #include directive is referred to as a special instruction for the C++ compiler which advises the compiler to include the contents of another file. Files which are included in software are known as include files or header files. We will be creating our own header files later. The #include directive provides an easy way of merging the source code from one file with the source code in another file, without retyping the code.

     

    In detail functions will be covered in the later courses. A function is referred to as a block of code which achieves a specific task. Each C++ program is equipped with a primary function known as main. This is recognized with a function header. A function header begins with the type of function (we will cover more on this later) followed by main ( ). After the function header the function code is enclosed in braces { }, which marks the beginning and ending of a function's code. Within this function the user will begin to code the software as it has been developed through the process of problem-solving. 

     

    int main ( )
    {
    //program body
    return 0;
    }//end of function

     

    Note: Please keep in mind that C++ is a case sensitive language, when keying in a C++ program. For example, by capitalizing the I in the #include directive the user will cause a syntax error, as C++ is expecting the character to be in a lower-case i. The variable ValueOne is NOT the same as valueOne.

     

    Executing a C++ program

    Post successful compilation of the software, the user is ready to attempt execution. Run the software multiple times and fully test using the desk-check data to verify the proper program operation.

     

    According to me Here are the Top Online C++ Compiler

    1. OnlineGDB
    2. Codepad
    3. Ideone
    4. Fiddle / JsFiddle – Online Editor For The Web
    5. JDoodle – Online IDE

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: