Basic Syntax and Structure of C++

#include <iostream>

int main() {
    // Print Hello, World! to the console
    cout << "Hello, World!";
    return 0;
}

//

#

 Directory

include

 should include this in the program

iostream

 Standard Input/Output header file

int

 datatype

main()

function name. It is the execution point of my program. i.e it is the place where my program begins.

{ } 

 Specifies a Block of code

return

It intimates to the compiler that the program has reached the end of the line

;

 Termination Statement


Example:

#include <iostream>

using namespace std; 

int main() {

     cout << "Hello, World!" << endl;  

        int a = 5, b = 3;

    int sum = a + b; 

      cout << "Sum of " << a << " and " << b << " is: " << sum << endl;

        return 0;

}


← Back Next →

Comments

Popular posts from this blog

Wrapper Class

Information Security & Essential Terminology

Information Security Threat Categories